[cfe-commits] r58148 - in /cfe/trunk: lib/Analysis/GRExprEngine.cpp test/Analysis/misc-ps.m

Ted Kremenek kremenek at apple.com
Sat Oct 25 13:09:23 PDT 2008


Author: kremenek
Date: Sat Oct 25 15:09:21 2008
New Revision: 58148

URL: http://llvm.org/viewvc/llvm-project?rev=58148&view=rev
Log:
Do not crash when performing VisitLValue on union types.
This fixes PR 2948.

Modified:
    cfe/trunk/lib/Analysis/GRExprEngine.cpp
    cfe/trunk/test/Analysis/misc-ps.m

Modified: cfe/trunk/lib/Analysis/GRExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/GRExprEngine.cpp?rev=58148&r1=58147&r2=58148&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/GRExprEngine.cpp (original)
+++ cfe/trunk/lib/Analysis/GRExprEngine.cpp Sat Oct 25 15:09:21 2008
@@ -457,9 +457,10 @@
       // can be used in a lvalue context.  We need to enhance our support
       // of such temporaries in both the environment and the store, so right
       // now we just do a regular visit.
-      assert (Ex->getType()->isAggregateType() && 
-              "Other kinds of expressions with non-aggregate types do not "
-              "have lvalues.");
+      assert ((Ex->getType()->isAggregateType() || 
+              Ex->getType()->isUnionType()) &&
+              "Other kinds of expressions with non-aggregate/union types do"
+              " not have lvalues.");
       
       Visit(Ex, Pred, Dst);
   }

Modified: cfe/trunk/test/Analysis/misc-ps.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/misc-ps.m?rev=58148&r1=58147&r2=58148&view=diff

==============================================================================
--- cfe/trunk/test/Analysis/misc-ps.m (original)
+++ cfe/trunk/test/Analysis/misc-ps.m Sat Oct 25 15:09:21 2008
@@ -43,3 +43,16 @@
   if (j == 0) x = x / 0;  // no-warning
 }
 
+// PR 2948 (testcase; crash on VisitLValue for union types)
+// http://llvm.org/bugs/show_bug.cgi?id=2948
+
+void checkaccess_union() {
+  int ret = 0, status;
+  if (((((__extension__ (((union {
+    __typeof (status) __in; int __i;}
+    )
+    {
+      .__in = (status)}
+      ).__i))) & 0xff00) >> 8) == 1)
+        ret = 1;
+}





More information about the cfe-commits mailing list