aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2010-03-16 21:50:59 +0000
committerJohn McCall <rjmccall@apple.com>2010-03-16 21:50:59 +0000
commit9a8cb8d4bdbb3eaf6e8cd8cb3e47b343694c01f8 (patch)
treee2d754af6e5652cb5a071f4bde5fd0d8ffe9bfa3
parent8472af4df9292e02fb25c952d25a81f3ca296252 (diff)
Forgot the testcases.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98685 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--test/Sema/warn-shadow.c20
-rw-r--r--test/SemaCXX/warn-shadow.cpp38
2 files changed, 58 insertions, 0 deletions
diff --git a/test/Sema/warn-shadow.c b/test/Sema/warn-shadow.c
new file mode 100644
index 0000000000..f75c140be1
--- /dev/null
+++ b/test/Sema/warn-shadow.c
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -Wshadow %s
+
+int i; // expected-note {{previous declaration is here}}
+
+void foo() {
+ int pass1;
+ int i; // expected-warning {{declaration shadows a variable in the global scope}} \
+ // expected-note {{previous declaration is here}}
+ {
+ int pass2;
+ int i; // expected-warning {{declaration shadows a local variable}} \
+ // expected-note {{previous declaration is here}}
+ {
+ int pass3;
+ int i; // expected-warning {{declaration shadows a local variable}}
+ }
+ }
+
+ int __sync_fetch_and_add; // expected-warning {{declaration shadows a global built-in function}}
+}
diff --git a/test/SemaCXX/warn-shadow.cpp b/test/SemaCXX/warn-shadow.cpp
new file mode 100644
index 0000000000..c637f42ea9
--- /dev/null
+++ b/test/SemaCXX/warn-shadow.cpp
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -Wshadow %s
+
+namespace {
+ int i; // expected-note {{previous declaration is here}}
+}
+
+namespace one {
+namespace two {
+ int j; // expected-note {{previous declaration is here}}
+}
+}
+
+namespace xx {
+ int m;
+}
+namespace yy {
+ int m;
+}
+
+using namespace one::two;
+using namespace xx;
+using namespace yy;
+
+void foo() {
+ int i; // expected-warning {{declaration shadows a variable in namespace '<anonymous>'}}
+ int j; // expected-warning {{declaration shadows a variable in namespace 'one::two'}}
+ int m;
+}
+
+class A {
+ static int data; // expected-note {{previous declaration}}
+ int field; // expected-note {{previous declaration}}
+
+ void test() {
+ char *field; // expected-warning {{declaration shadows a field of 'A'}}
+ char *data; // expected-warning {{declaration shadows a static data member of 'A'}}
+ }
+};