aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Carlini <paolo.carlini@oracle.com>2018-12-12 21:36:26 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2018-12-12 21:36:26 +0000
commit77a242860085d70b33d12302ca8c729f0c060905 (patch)
tree344b71ff608685675673e3228e358315c8ba5a0b
parent293267bcdf1f32f624606b0087fa97731f1d08f7 (diff)
downloadgcc-77a242860085d70b33d12302ca8c729f0c060905.zip
gcc-77a242860085d70b33d12302ca8c729f0c060905.tar.gz
gcc-77a242860085d70b33d12302ca8c729f0c060905.tar.bz2
decl.c (grokdeclarator): Fix location of error message about static data member definition.
/cp 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. From-SVN: r267066
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/decl.c3
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/g++.dg/other/static5.C8
4 files changed, 19 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 2c1f392..a32e1d0 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 9b0ea70..5435ef2 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -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;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 2fbf69c..856dfdf 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
diff --git a/gcc/testsuite/g++.dg/other/static5.C b/gcc/testsuite/g++.dg/other/static5.C
new file mode 100644
index 0000000..007b7c3
--- /dev/null
+++ b/gcc/testsuite/g++.dg/other/static5.C
@@ -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" }