summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-12-18 06:50:14 +0000
committerChris Lattner <sabre@nondot.org>2008-12-18 06:50:14 +0000
commitb6ec4e75ad1147dea55cb9e9c150c53fedfe9e1f (patch)
tree611aefe1a0617c0f06ff68e626a6ab0c2dcba2a9 /clang/lib
parentc3a70ade66e0de775cd054353ded2e0c870cfe5b (diff)
downloadbcm5719-llvm-b6ec4e75ad1147dea55cb9e9c150c53fedfe9e1f.tar.gz
bcm5719-llvm-b6ec4e75ad1147dea55cb9e9c150c53fedfe9e1f.zip
Clean up the C89/C++ warnings about C99 array features to not
emit duplicate diags (some in parser and some in sema) and to warn about use of typequals in array sizes. This implements PR2759. llvm-svn: 61197
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Parse/ParseDecl.cpp17
-rw-r--r--clang/lib/Sema/SemaType.cpp12
2 files changed, 12 insertions, 17 deletions
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index 1a8e5d9f955..e31b87bd432 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -1283,7 +1283,7 @@ void Parser::ParseTypeQualifierListOpt(DeclSpec &DS) {
DS.AddAttributes(ParseAttributes());
continue; // do *not* consume the next token!
}
-
+
// If the specifier combination wasn't legal, issue a diagnostic.
if (isInvalid) {
assert(PrevSpec && "Method did not return previous specifier!");
@@ -1943,6 +1943,7 @@ void Parser::ParseBracketDeclarator(Declarator &D) {
StaticLoc = ConsumeToken();
// If there is a type-qualifier-list, read it now.
+ // Type qualifiers in an array subscript are a C99 feature.
DeclSpec DS;
ParseTypeQualifierListOpt(DS);
@@ -1962,9 +1963,10 @@ void Parser::ParseBracketDeclarator(Declarator &D) {
if (Tok.is(tok::star) && GetLookAheadToken(1).is(tok::r_square)) {
ConsumeToken(); // Eat the '*'.
- if (StaticLoc.isValid())
+ if (StaticLoc.isValid()) {
Diag(StaticLoc, diag::err_unspecified_vla_size_with_static);
- StaticLoc = SourceLocation(); // Drop the static.
+ StaticLoc = SourceLocation(); // Drop the static.
+ }
isStar = true;
} else if (Tok.isNot(tok::r_square)) {
// Parse the assignment-expression now.
@@ -1980,15 +1982,6 @@ void Parser::ParseBracketDeclarator(Declarator &D) {
MatchRHSPunctuation(tok::r_square, StartLoc);
- // If C99 isn't enabled, emit an ext-warn if the arg list wasn't empty and if
- // it was not a constant expression.
- if (!getLang().C99) {
- // TODO: check C90 array constant exprness.
- if (isStar || StaticLoc.isValid() ||
- 0/*TODO: NumElts is not a C90 constantexpr */)
- Diag(StartLoc, diag::ext_c99_array_usage);
- }
-
// Remember that we parsed a pointer type, and remember the type-quals.
D.AddTypeInfo(DeclaratorChunk::getArray(DS.getTypeQualifiers(),
StaticLoc.isValid(), isStar,
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 3f911f5b0cd..a6441c8d704 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -416,11 +416,13 @@ QualType Sema::GetTypeForDeclarator(Declarator &D, Scope *S, unsigned Skip) {
T = Context.getConstantArrayType(T, ConstVal, ASM, ATI.TypeQuals);
}
// If this is not C99, extwarn about VLA's and C99 array size modifiers.
- if (!getLangOptions().C99 &&
- (ASM != ArrayType::Normal ||
- (ArraySize && !ArraySize->isValueDependent() &&
- !ArraySize->isIntegerConstantExpr(Context))))
- Diag(D.getIdentifierLoc(), diag::ext_vla);
+ if (!getLangOptions().C99) {
+ if (ArraySize && !ArraySize->isValueDependent() &&
+ !ArraySize->isIntegerConstantExpr(Context))
+ Diag(D.getIdentifierLoc(), diag::ext_vla);
+ else if (ASM != ArrayType::Normal || ATI.TypeQuals != 0)
+ Diag(D.getIdentifierLoc(), diag::ext_c99_array_usage);
+ }
break;
}
case DeclaratorChunk::Function:
OpenPOWER on IntegriCloud