Parser: Array decls with static but without array size are illformed
Array declarators involving the static keyword take on two forms:
D[ static type-qualifier-listopt assignment-expression ]
D[ type-qualifier-list static assignment-expression ]
Raise a diagnostic if the assignment-expression is missing.
This fixes PR20584.
llvm-svn: 215187
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index 727915c..b471365 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -5596,6 +5596,11 @@
Sema::ConstantEvaluated);
NumElements = ParseAssignmentExpression();
}
+ } else {
+ if (StaticLoc.isValid()) {
+ Diag(StaticLoc, diag::err_unspecified_size_with_static);
+ StaticLoc = SourceLocation(); // Drop the static.
+ }
}
// If there was an error parsing the assignment-expression, recover.