r178631 - Assert that Parser::ParseStructUnionBody is not called for C++ code.

Andy Gibbs andyg1001 at hotmail.co.uk
Wed Apr 3 02:31:19 PDT 2013


Author: andyg
Date: Wed Apr  3 04:31:19 2013
New Revision: 178631

URL: http://llvm.org/viewvc/llvm-project?rev=178631&view=rev
Log:
Assert that Parser::ParseStructUnionBody is not called for C++ code.

Modified:
    cfe/trunk/lib/Parse/ParseDecl.cpp

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=178631&r1=178630&r2=178631&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Wed Apr  3 04:31:19 2013
@@ -3066,6 +3066,7 @@ void Parser::ParseStructUnionBody(Source
                                   unsigned TagType, Decl *TagDecl) {
   PrettyDeclStackTraceEntry CrashInfo(Actions, TagDecl, RecordLoc,
                                       "parsing struct/union body");
+  assert(!getLangOpts().CPlusPlus && "C++ declarations not supported");
 
   BalancedDelimiterTracker T(*this, tok::l_brace);
   if (T.consumeOpen())
@@ -3074,9 +3075,8 @@ void Parser::ParseStructUnionBody(Source
   ParseScope StructScope(this, Scope::ClassScope|Scope::DeclScope);
   Actions.ActOnTagStartDefinition(getCurScope(), TagDecl);
 
-  // Empty structs are an extension in C (C99 6.7.2.1p7), but are allowed in
-  // C++.
-  if (Tok.is(tok::r_brace) && !getLangOpts().CPlusPlus) {
+  // Empty structs are an extension in C (C99 6.7.2.1p7).
+  if (Tok.is(tok::r_brace)) {
     Diag(Tok, diag::ext_empty_struct_union) << (TagType == TST_union);
     Diag(Tok, diag::warn_empty_struct_union_compat) << (TagType == TST_union);
   }





More information about the cfe-commits mailing list