summaryrefslogtreecommitdiffstats
path: root/clang/test/Sema/uninit-variables.c
diff options
context:
space:
mode:
authorRichard Trieu <rtrieu@google.com>2012-05-03 01:09:59 +0000
committerRichard Trieu <rtrieu@google.com>2012-05-03 01:09:59 +0000
commit2cdcf82396b5e745f153d1503491007a988291df (patch)
treebe342814e75dfa5e6bfe72836e147776431039c3 /clang/test/Sema/uninit-variables.c
parent78453eed1219b83dff87d34a4bbbe48cc65eda70 (diff)
downloadbcm5719-llvm-2cdcf82396b5e745f153d1503491007a988291df.tar.gz
bcm5719-llvm-2cdcf82396b5e745f153d1503491007a988291df.zip
Fix a note without a SourceLocation.
#define TEST int y; int x = y; void foo() { TEST } -Wuninitialized gives this warning: invalid-loc.cc:4:3: warning: variable 'y' is uninitialized when used here [-Wuninitialized] TEST ^~~~ invalid-loc.cc:2:29: note: expanded from macro 'TEST' #define TEST int y; int x = y; ^ note: initialize the variable 'y' to silence this warning 1 warning generated. The second note lacks filename, line number, and code snippet. This change will remove the fixit and only point to variable declaration. invalid-loc.cc:4:3: warning: variable 'y' is uninitialized when used here [-Wuninitialized] TEST ^~~~ invalid-loc.cc:2:29: note: expanded from macro 'TEST' #define TEST int y; int x = y; ^ invalid-loc.cc:4:3: note: variable 'y' is declared here TEST ^ invalid-loc.cc:2:14: note: expanded from macro 'TEST' #define TEST int y; int x = y; ^ 1 warning generated. llvm-svn: 156045
Diffstat (limited to 'clang/test/Sema/uninit-variables.c')
-rw-r--r--clang/test/Sema/uninit-variables.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/clang/test/Sema/uninit-variables.c b/clang/test/Sema/uninit-variables.c
index d62186df731..30db640323e 100644
--- a/clang/test/Sema/uninit-variables.c
+++ b/clang/test/Sema/uninit-variables.c
@@ -424,3 +424,13 @@ void rdar9432305(float *P) {
for (; i < 10000; ++i) // expected-warning {{variable 'i' is uninitialized when used here}}
P[i] = 0.0f;
}
+
+// Test that fixits are not emitted inside macros.
+#define UNINIT(T, x, y) T x; T y = x;
+#define ASSIGN(T, x, y) T y = x;
+void test54() {
+ UNINIT(int, a, b); // expected-warning {{variable 'a' is uninitialized when used here}} \
+ // expected-note {{variable 'a' is declared here}}
+ int c; // expected-note {{initialize the variable 'c' to silence this warning}}
+ ASSIGN(int, c, d); // expected-warning {{variable 'c' is uninitialized when used here}}
+}
OpenPOWER on IntegriCloud