decl.c (grokdeclarator): Fix location of error message about static data member defin...
authorPaolo Carlini <paolo.carlini@oracle.com>
Wed, 12 Dec 2018 21:36:26 +0000 (21:36 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Wed, 12 Dec 2018 21:36:26 +0000 (21:36 +0000)
/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

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/other/static5.C [new file with mode: 0644]

index 2c1f39288c43bd288009f0e5c9a0b2117bcdc320..a32e1d05491a82205de3dbcdcf8df8d7a39d5c2a 100644 (file)
@@ -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
index 9b0ea702ec46ad37f1ff170c23ec13037830b97e..5435ef2c8249c4d8819438930ad2e9dbd6b4faa0 100644 (file)
@@ -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;
index 2fbf69c3067265a8ab6148e5e0d3206540529d21..856dfdf8d4593798c65eafa6199d023499237421 100644 (file)
@@ -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 (file)
index 0000000..007b7c3
--- /dev/null
@@ -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" }