@@ -19016,10 +19017,22 @@ cp_parser_direct_declarator (cp_parser* parser,
cp_lexer_consume_token (parser->lexer);
/* Peek at the next token. */
token = cp_lexer_peek_token (parser->lexer);
+
+ /* If static keyword immediately follows [, report error. */
+ if (cp_lexer_next_token_is_keyword (parser->lexer, RID_STATIC)
+ && current_binding_level->kind == sk_function_parms)
+ {
+ error_at (token->location,
+ "static array size is a C99 feature,"
+ "not permitted in C++");
+ bounds = error_mark_node;
+ }
+
/* If the next token is `]', then there is no
constant-expression. */
- if (token->type != CPP_CLOSE_SQUARE)
+ else if (token->type != CPP_CLOSE_SQUARE)
{
+
bool non_constant_p;
bounds
= cp_parser_constant_expression (parser,
new file mode 100644
@@ -0,0 +1,6 @@
+// { dg-do compile }
+
+void f(int a[static 10]); /* { dg-error "static array size is a C99 feature" } */
+/* { dg-error "expected ']' before 'static'" "" { target *-*-* } 3 } */
+/* { dg-error "expected ')' before 'static'" "" { target *-*-* } 3 } */
+/* { dg-error "expected initializer before 'static'" "" { target *-*-* } 3 } */