]> granicus.if.org Git - clang/commitdiff
implement PR3177 - "__extension__ union" not supported in C++ mode
authorChris Lattner <sabre@nondot.org>
Thu, 18 Dec 2008 01:12:00 +0000 (01:12 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 18 Dec 2008 01:12:00 +0000 (01:12 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61180 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Parse/ParseDeclCXX.cpp
test/Parser/cxx-class.cpp

index ec2a37a852408aa669281988f255f5d15e19011d..eaada1c26cb7be5ad5a87ba6d94cf1a930884ec1 100644 (file)
@@ -16,6 +16,7 @@
 #include "clang/Parse/DeclSpec.h"
 #include "clang/Parse/Scope.h"
 #include "AstGuard.h"
+#include "ExtensionRAIIObject.h"
 using namespace clang;
 
 /// ParseNamespace - We know that the current token is a namespace keyword. This
@@ -408,6 +409,7 @@ AccessSpecifier Parser::getAccessSpecifierIfPresent() const
 ///         using-declaration                                            [TODO]
 /// [C++0x] static_assert-declaration                                    [TODO]
 ///         template-declaration                                         [TODO]
+/// [GNU]   '__extension__' member-declaration
 ///
 ///       member-declarator-list:
 ///         member-declarator
@@ -425,6 +427,14 @@ AccessSpecifier Parser::getAccessSpecifierIfPresent() const
 ///         '=' constant-expression
 ///
 Parser::DeclTy *Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS) {
+  // Handle:  member-declaration ::= '__extension__' member-declaration
+  if (Tok.is(tok::kw___extension__)) {
+    // __extension__ silences extension warnings in the subexpression.
+    ExtensionRAIIObject O(Diags);  // Use RAII to do this.
+    ConsumeToken();
+    return ParseCXXClassMemberDeclaration(AS);
+  }
+  
   SourceLocation DSStart = Tok.getLocation();
   // decl-specifier-seq:
   // Parse the common declaration-specifiers piece.
index 5afa8d6ac23977e5ea42db1e7de6eb0c4286988e..39b787fc8dcd8765a5863d204be2bc1e43c94603 100644 (file)
@@ -27,3 +27,12 @@ void glo()
 {
   struct local {};
 }
+
+// PR3177
+typedef union {
+  __extension__ union {
+    int a;
+    float b;
+  } y;
+} bug3177;
+