PR c++/51463
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 15 Dec 2011 20:45:53 +0000 (20:45 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 15 Dec 2011 20:45:53 +0000 (20:45 +0000)
* decl.c (grokdeclarator): Set DECL_INITIAL of decl
to error_mark_node to disallow NSDMI if declspecs->storage_class
is sc_static.
* parser.c (cp_parser_late_parse_one_default_arg): Return early
if default_arg is error_mark_node.

* g++.dg/cpp0x/pr51463.C: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@182387 138bc75d-0d04-0410-961f-82ee72b054a4

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

index 3975b6b..c9ada9a 100644 (file)
@@ -1,5 +1,12 @@
 2011-12-15  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/51463
+       * decl.c (grokdeclarator): Set DECL_INITIAL of decl
+       to error_mark_node to disallow NSDMI if declspecs->storage_class
+       is sc_static.
+       * parser.c (cp_parser_late_parse_one_default_arg): Return early
+       if default_arg is error_mark_node.
+
        PR c/51360
        * semantics.c (finish_omp_clauses): For OMP_CLAUSE_NUM_THREADS_EXPR
        and OMP_CLAUSE_SCHEDULE_CHUNK_EXPR call mark_rvalue_use.
index 1fe63bb..1239535 100644 (file)
@@ -10220,9 +10220,17 @@ grokdeclarator (const cp_declarator *declarator,
                  }
 
                if (initialized)
-                 /* An attempt is being made to initialize a non-static
-                    member.  This is new in C++11.  */
-                 maybe_warn_cpp0x (CPP0X_NSDMI);
+                 {
+                   /* An attempt is being made to initialize a non-static
+                      member.  This is new in C++11.  */
+                   maybe_warn_cpp0x (CPP0X_NSDMI);
+
+                   /* If this has been parsed with static storage class, but
+                      errors forced staticp to be cleared, ensure NSDMI is
+                      not present.  */
+                   if (declspecs->storage_class == sc_static)
+                     DECL_INITIAL (decl) = error_mark_node;
+                 }
              }
 
            bad_specifiers (decl, BSP_FIELD, virtualp,
index 9301e53..30c7745 100644 (file)
@@ -21853,6 +21853,9 @@ cp_parser_late_parse_one_default_arg (cp_parser *parser, tree decl,
   tree parsed_arg;
   bool dummy;
 
+  if (default_arg == error_mark_node)
+    return error_mark_node;
+
   /* Push the saved tokens for the default argument onto the parser's
      lexer stack.  */
   tokens = DEFARG_TOKENS (default_arg);
index 67d91ba..1b84ff9 100644 (file)
@@ -1,11 +1,14 @@
 2011-12-15  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/51463
+       * g++.dg/cpp0x/pr51463.C: New test.
+
        PR c/51360
        * c-c++-common/gomp/pr51360.c: New test.
        * g++.dg/gomp/pr51360.C: New test.
 
        PR middle-end/49806
-       * gcc.dg/tree-ssa-vrp47.c: Add -fdump-tree-dom2 to dg-options.
+       * gcc.dg/tree-ssa/vrp47.c: Add -fdump-tree-dom2 to dg-options.
        Check for x_? & y in dom2 dump and xfail the check in dom1 dump.
 
        PR tree-optimization/51117
diff --git a/gcc/testsuite/g++.dg/cpp0x/pr51463.C b/gcc/testsuite/g++.dg/cpp0x/pr51463.C
new file mode 100644 (file)
index 0000000..1e8be3b
--- /dev/null
@@ -0,0 +1,8 @@
+// PR c++/51463
+// { dg-do compile }
+// { dg-options "-std=c++11" }
+
+struct A
+{
+  static virtual int i = 0;    // { dg-error "both virtual and static|declared as" }
+};