Diagnose use of compound literals in C90 code
llvm-svn: 38876
This commit is contained in:
parent
b7f1fc95d3
commit
6c3f05d1d2
|
@ -565,13 +565,15 @@ Parser::ExprResult Parser::ParseParenExpression(ParenParseOption &ExprType) {
|
|||
ParseCompoundStatement();
|
||||
ExprType = CompoundStmt;
|
||||
} else if (ExprType >= CompoundLiteral && isTypeSpecifierQualifier()) {
|
||||
// Otherwise, this is a compound expression.
|
||||
// Otherwise, this is a compound literal expression or cast expression.
|
||||
ParseTypeName();
|
||||
|
||||
// Match the ')'.
|
||||
MatchRHSPunctuation(tok::r_paren, OpenLoc, "(", diag::err_expected_rparen);
|
||||
|
||||
if (Tok.getKind() == tok::l_brace) {
|
||||
if (!getLang().C99) // Compound literals don't exist in C90.
|
||||
Diag(OpenLoc, diag::ext_c99_compound_literal);
|
||||
Result = ParseInitializer();
|
||||
ExprType = CompoundLiteral;
|
||||
} else if (ExprType == CastExpr) {
|
||||
|
|
|
@ -253,9 +253,12 @@ DIAG(ext_thread_before, EXTENSION,
|
|||
DIAG(ext_ident_list_in_param, EXTENSION,
|
||||
"type-less parameter names in function declaration")
|
||||
DIAG(ext_c99_array_usage, EXTENSION,
|
||||
"use of c99-specific array features")
|
||||
"use of C99-specific array features")
|
||||
DIAG(ext_c99_variable_decl_in_for_loop, EXTENSION,
|
||||
"variable declaration in for loop is a c99-specific feature")
|
||||
"variable declaration in for loop is a C99-specific feature")
|
||||
DIAG(ext_c99_compound_literal, EXTENSION,
|
||||
"compound literals are a C99-specific feature")
|
||||
|
||||
DIAG(ext_gnu_indirect_goto, EXTENSION,
|
||||
"use of GNU indirect-goto extension")
|
||||
DIAG(ext_gnu_address_of_label, EXTENSION,
|
||||
|
|
Loading…
Reference in New Issue