[cfe-commits] r149460 - in /cfe/trunk: lib/Sema/SemaDecl.cpp test/Sema/MicrosoftExtensions.c

Nico Weber nicolasweber at gmx.de
Tue Jan 31 16:41:00 PST 2012


Author: nico
Date: Tue Jan 31 18:41:00 2012
New Revision: 149460

URL: http://llvm.org/viewvc/llvm-project?rev=149460&view=rev
Log:
Fix crash on invalid in microsoft anonymous struct extension.

Fixes PR11847. Patch from Jason Haslam!


Modified:
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/test/Sema/MicrosoftExtensions.c

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=149460&r1=149459&r2=149460&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Jan 31 18:41:00 2012
@@ -2952,9 +2952,10 @@
   SmallVector<NamedDecl*, 2> Chain;
   Chain.push_back(Anon);
 
-  if (InjectAnonymousStructOrUnionMembers(*this, S, CurContext,
-                                          Record->getDefinition(),
-                                          AS_none, Chain, true))
+  RecordDecl *RecordDef = Record->getDefinition();
+  if (!RecordDef || InjectAnonymousStructOrUnionMembers(*this, S, CurContext,
+                                                        RecordDef, AS_none,
+                                                        Chain, true))
     Anon->setInvalidDecl();
 
   return Anon;

Modified: cfe/trunk/test/Sema/MicrosoftExtensions.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/MicrosoftExtensions.c?rev=149460&r1=149459&r2=149460&view=diff
==============================================================================
--- cfe/trunk/test/Sema/MicrosoftExtensions.c (original)
+++ cfe/trunk/test/Sema/MicrosoftExtensions.c Tue Jan 31 18:41:00 2012
@@ -86,4 +86,13 @@
    short sh = (short)ptr;
    ch = (char)ptr;
    sh = (short)ptr;
-} 
+}
+
+
+typedef struct {
+  UNKNOWN u; // expected-error {{unknown type name 'UNKNOWN'}}
+} AA;
+
+typedef struct {
+  AA; // expected-warning {{anonymous structs are a Microsoft extension}}
+} BB;





More information about the cfe-commits mailing list