]> granicus.if.org Git - clang/commitdiff
Fix assertion failure in UninitializedValues.cpp where an lvalue to rvalue conversion...
authorTed Kremenek <kremenek@apple.com>
Tue, 19 Jul 2011 20:33:49 +0000 (20:33 +0000)
committerTed Kremenek <kremenek@apple.com>
Tue, 19 Jul 2011 20:33:49 +0000 (20:33 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135519 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/UninitializedValues.cpp
test/Sema/uninit-variables.c

index 8dbade1d5f325be464386405c21c6f952ed67632..a64c1db530d0b2f1659dec3fd9551480f9e6facf 100644 (file)
@@ -462,7 +462,8 @@ void TransferFunctions::VisitDeclStmt(DeclStmt *ds) {
           // appropriately, but we need to continue to analyze subsequent uses
           // of the variable.
           if (init == lastLoad) {
-            DeclRefExpr *DR = cast<DeclRefExpr>(lastLoad->getSubExpr());
+            DeclRefExpr *DR =
+              cast<DeclRefExpr>(lastLoad->getSubExpr()->IgnoreParens());
             vals[vd] = (DR->getDecl() == vd) ? Uninitialized : Initialized;
             lastLoad = 0;
             if (lastDR == DR)
@@ -562,7 +563,7 @@ void TransferFunctions::ProcessUses(Stmt *s) {
     // If we reach here, we have seen a load of an uninitialized value
     // and it hasn't been casted to void or otherwise handled.  In this
     // situation, report the incident.
-    DeclRefExpr *DR = cast<DeclRefExpr>(lastLoad->getSubExpr());
+    DeclRefExpr *DR = cast<DeclRefExpr>(lastLoad->getSubExpr()->IgnoreParens());
     VarDecl *VD = cast<VarDecl>(DR->getDecl());
     reportUninit(DR, VD, isAlwaysUninit(vals[VD]));
     lastLoad = 0;
index 0caab3df18c04902cf0e2573783f9a0e5eef5d8d..6c3c7c71c84554d5e70dd11fc14878f51a6306d2 100644 (file)
@@ -353,6 +353,11 @@ int test52(int a, int b) {
   return x; // expected-warning {{variable 'x' may be uninitialized when used here}}
 }
 
+void test53() {
+  int x;
+  int y = (x);
+}
+
 // This CFG caused the uninitialized values warning to inf-loop.
 extern int PR10379_g();
 void PR10379_f(int *len) {