[cfe-commits] r38876 - in /cfe/cfe/trunk: Parse/ParseExpr.cpp include/clang/Basic/DiagnosticKinds.def

sabre at cs.uiuc.edu sabre at cs.uiuc.edu
Wed Jul 11 09:25:24 PDT 2007


Author: sabre
Date: Wed Jul 11 11:25:24 2007
New Revision: 38876

URL: http://llvm.org/viewvc/llvm-project?rev=38876&view=rev
Log:
Diagnose use of compound literals in C90 code

Modified:
    cfe/cfe/trunk/Parse/ParseExpr.cpp
    cfe/cfe/trunk/include/clang/Basic/DiagnosticKinds.def

Modified: cfe/cfe/trunk/Parse/ParseExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Parse/ParseExpr.cpp?rev=38876&r1=38875&r2=38876&view=diff

==============================================================================
--- cfe/cfe/trunk/Parse/ParseExpr.cpp (original)
+++ cfe/cfe/trunk/Parse/ParseExpr.cpp Wed Jul 11 11:25:24 2007
@@ -565,13 +565,15 @@
     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) {

Modified: cfe/cfe/trunk/include/clang/Basic/DiagnosticKinds.def
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/include/clang/Basic/DiagnosticKinds.def?rev=38876&r1=38875&r2=38876&view=diff

==============================================================================
--- cfe/cfe/trunk/include/clang/Basic/DiagnosticKinds.def (original)
+++ cfe/cfe/trunk/include/clang/Basic/DiagnosticKinds.def Wed Jul 11 11:25:24 2007
@@ -253,9 +253,12 @@
 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,





More information about the cfe-commits mailing list