Skip to content

Commit

Permalink
/cp
Browse files Browse the repository at this point in the history
2018-12-12  Paolo Carlini  <paolo.carlini@oracle.com>

	* decl.c (grokdeclarator): Fix location of error message about
	static data member definition.

/testsuite
2018-12-12  Paolo Carlini  <paolo.carlini@oracle.com>

	* g++.dg/other/static5.C: New.


git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@267066 138bc75d-0d04-0410-961f-82ee72b054a4
  • Loading branch information
paolo committed Dec 12, 2018
1 parent 488d338 commit 4a8a652
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
5 changes: 5 additions & 0 deletions gcc/cp/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2018-12-12 Paolo Carlini <paolo.carlini@oracle.com>

* decl.c (grokdeclarator): Fix location of error message about
static data member definition.

2018-12-12 Jakub Jelinek <jakub@redhat.com>

PR c++/88446
Expand Down
3 changes: 2 additions & 1 deletion gcc/cp/decl.c
Original file line number Diff line number Diff line change
Expand Up @@ -12724,7 +12724,8 @@ grokdeclarator (const cp_declarator *declarator,
DECL_CONTEXT (decl) = ctype;
if (staticp == 1)
{
permerror (input_location, "%<static%> may not be used when defining "
permerror (declspecs->locations[ds_storage_class],
"%<static%> may not be used when defining "
"(as opposed to declaring) a static data member");
staticp = 0;
storage_class = sc_none;
Expand Down
4 changes: 4 additions & 0 deletions gcc/testsuite/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
2018-12-12 Paolo Carlini <paolo.carlini@oracle.com>

* g++.dg/other/static5.C: New.

2018-12-12 Segher Boessenkool <segher@kernel,crashing.org>

PR testsuite/88318
Expand Down
8 changes: 8 additions & 0 deletions gcc/testsuite/g++.dg/other/static5.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
struct S
{
static int i;
const static double d;
};

static int S::i; // { dg-error "1:.static. may not be used" }
const static double S::d = 1.0; // { dg-error "7:.static. may not be used" }

0 comments on commit 4a8a652

Please sign in to comment.