@@ -10214,9 +10214,17 @@ grokdeclarator (const cp_declarator *dec
}
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,
@@ -21848,6 +21848,9 @@ cp_parser_late_parse_one_default_arg (cp
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);
@@ -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" }
+};