[cfe-commits] r135217 - in /cfe/trunk: lib/Analysis/UninitializedValues.cpp test/Sema/uninit-variables.c
Ted Kremenek
kremenek at apple.com
Thu Jul 14 16:43:06 PDT 2011
Author: kremenek
Date: Thu Jul 14 18:43:06 2011
New Revision: 135217
URL: http://llvm.org/viewvc/llvm-project?rev=135217&view=rev
Log:
Fix false negative reported in PR 10358 by using 'Unknown' in -Wuninitialized to avoid cascading warnings. Patch by Kaelyn Uhrain.
Modified:
cfe/trunk/lib/Analysis/UninitializedValues.cpp
cfe/trunk/test/Sema/uninit-variables.c
Modified: cfe/trunk/lib/Analysis/UninitializedValues.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/UninitializedValues.cpp?rev=135217&r1=135216&r2=135217&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/UninitializedValues.cpp (original)
+++ cfe/trunk/lib/Analysis/UninitializedValues.cpp Thu Jul 14 18:43:06 2011
@@ -495,9 +495,11 @@
ValueVector::reference val = vals[vd];
if (isUninitialized(val)) {
- if (bo->getOpcode() != BO_Assign)
+ if (bo->getOpcode() != BO_Assign) {
reportUninit(res.getDeclRefExpr(), vd, isAlwaysUninit(val));
- val = Initialized;
+ val = Unknown;
+ } else
+ val = Initialized;
}
return;
}
@@ -526,7 +528,7 @@
if (isUninitialized(val)) {
reportUninit(res.getDeclRefExpr(), vd, isAlwaysUninit(val));
// Don't cascade warnings.
- val = Initialized;
+ val = Unknown;
}
return;
}
@@ -558,7 +560,7 @@
if (isUninitialized(val)) {
reportUninit(res.getDeclRefExpr(), vd, isAlwaysUninit(val));
// Don't cascade warnings.
- vals[vd] = Initialized;
+ vals[vd] = Unknown;
}
}
return;
Modified: cfe/trunk/test/Sema/uninit-variables.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/uninit-variables.c?rev=135217&r1=135216&r2=135217&view=diff
==============================================================================
--- cfe/trunk/test/Sema/uninit-variables.c (original)
+++ cfe/trunk/test/Sema/uninit-variables.c Thu Jul 14 18:43:06 2011
@@ -77,7 +77,7 @@
}
void test12(unsigned n) {
- for (unsigned i ; n ; ++i) ; // expected-warning{{variable 'i' may be uninitialized when used here}} expected-note{{variable 'i' is declared here}} expected-note{{add initialization to silence this warning}}
+ for (unsigned i ; n ; ++i) ; // expected-warning{{variable 'i' is uninitialized when used here}} expected-note{{variable 'i' is declared here}} expected-note{{add initialization to silence this warning}}
}
int test13() {
@@ -237,7 +237,7 @@
void **pc; // expected-note{{variable 'pc' is declared here}} expected-note{{add initialization to silence this warning}}
void *dummy[] = { &&L1, &&L2 };
L1:
- goto *pc; // expected-warning{{variable 'pc' may be uninitialized when used here}}
+ goto *pc; // expected-warning{{variable 'pc' is uninitialized when used here}}
L2:
goto *pc;
}
@@ -289,7 +289,7 @@
void test43(int i) {
int x; // expected-note {{variable 'x' is declared here}} expected-note{{add initialization to silence this warning}}
for (i = 0 ; i < 10; i++)
- test43_aux(x++); // expected-warning {{variable 'x' may be uninitialized when used here}}
+ test43_aux(x++); // expected-warning {{variable 'x' is uninitialized when used here}}
}
void test44(int i) {
@@ -297,7 +297,7 @@
int y; // expected-note {{variable 'y' is declared here}} expected-note{{add initialization to silence this warning}}
for (i = 0; i < 10; i++ ) {
test43_aux(x++); // no-warning
- x += y; // expected-warning {{variable 'y' may be uninitialized when used here}}
+ x += y; // expected-warning {{variable 'y' is uninitialized when used here}}
}
}
More information about the cfe-commits
mailing list