summaryrefslogtreecommitdiff
path: root/test/SemaCXX/warn-shadow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/SemaCXX/warn-shadow.cpp')
-rw-r--r--test/SemaCXX/warn-shadow.cpp69
1 files changed, 56 insertions, 13 deletions
diff --git a/test/SemaCXX/warn-shadow.cpp b/test/SemaCXX/warn-shadow.cpp
index 3d09c786285ad..f4a904b7ed379 100644
--- a/test/SemaCXX/warn-shadow.cpp
+++ b/test/SemaCXX/warn-shadow.cpp
@@ -59,13 +59,13 @@ class A {
// expected-warning-re@+1 4 {{constructor parameter 'f{{[0-4]}}' shadows the field 'f{{[0-9]}}' of 'A'}}
A(int f1, int f2, int f3, int f4, double overload_dummy) {}
- void test() {
- char *field; // expected-warning {{declaration shadows a field of 'A'}}
- char *data; // expected-warning {{declaration shadows a static data member of 'A'}}
+ void test() {
+ char *field; // expected-warning {{declaration shadows a field of 'A'}}
+ char *data; // expected-warning {{declaration shadows a static data member of 'A'}}
char *a1; // no warning
- char *a2; // no warning
- char *jj; // no warning
- char *jjj; // no warning
+ char *a2; // no warning
+ char *jj; // no warning
+ char *jjj; // no warning
}
void test2() {
@@ -196,14 +196,14 @@ void avoidWarningWhenRedefining(int b) { // expected-note {{previous definition
int k; // expected-note {{previous definition is here}}
typedef int k; // expected-error {{redefinition of 'k'}}
- using l=char; // no warning or error.
- using l=char; // no warning or error.
- typedef char l; // no warning or error.
+ using l=char; // no warning or error.
+ using l=char; // no warning or error.
+ typedef char l; // no warning or error.
typedef char n; // no warning or error.
typedef char n; // no warning or error.
- using n=char; // no warning or error.
-}
+ using n=char; // no warning or error.
+}
}
@@ -219,6 +219,49 @@ void f(int a) {
struct A {
void g(int a) {}
A() { int a; }
+ };
+}
+}
+
+namespace PR34120 {
+struct A {
+ int B; // expected-note 2 {{declared here}}
+};
+
+class C : public A {
+ void D(int B) {} // expected-warning {{parameter 'B' shadows member inherited from type 'A'}}
+ void E() {
+ extern void f(int B); // Ok
+ }
+ void F(int B); // Ok, declaration; not definition.
+ void G(int B);
+};
+
+void C::G(int B) { // expected-warning {{parameter 'B' shadows member inherited from type 'A'}}
+}
+
+class Private {
+ int B;
+};
+class Derived : Private {
+ void D(int B) {} // Ok
+};
+
+struct Static {
+ static int B;
+};
+
+struct Derived2 : Static {
+ void D(int B) {}
+};
+}
+
+int PR24718;
+enum class X { PR24718 }; // Ok, not shadowing
+
+struct PR24718_1;
+struct PR24718_2 {
+ enum {
+ PR24718_1 // Does not shadow a type.
};
-}
-}
+};