]> granicus.if.org Git - clang/commitdiff
Assert that Parser::ParseStructUnionBody is not called for C++ code.
authorAndy Gibbs <andyg1001@hotmail.co.uk>
Wed, 3 Apr 2013 09:31:19 +0000 (09:31 +0000)
committerAndy Gibbs <andyg1001@hotmail.co.uk>
Wed, 3 Apr 2013 09:31:19 +0000 (09:31 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178631 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Parse/ParseDecl.cpp

index 87b8a2d906c7133382739e615af09e9c6cb8d277..589723a1d1d341755f414053c2483c9583a4bbeb 100644 (file)
@@ -3066,6 +3066,7 @@ void Parser::ParseStructUnionBody(SourceLocation RecordLoc,
                                   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(SourceLocation RecordLoc,
   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);
   }