Debian Codegraph @

gcc/testsuite/g++.dg/warn/Wshadow-5.C

raw
1 // Wshadows was giving warnings for nested function parameters in nested class
2 // or structure that we didn't want.
3 // { dg-do compile }
4 // { dg-options "-Wshadow -Wno-return-type" }
5
6 // PR c++/41825
7 int f (int n)
8 {
9 int bar (int n) { return n++; } // { dg-error "a function-definition is not allowed here" }
10 return bar (n); // { dg-error "12:'bar' was not declared in this scope" }
11 }
12
13 int g (int i)
14 {
15 struct {
16 int bar (int i) { return i++; } // { dg-bogus "shadows" }
17 } s;
18
19 return s.bar (i);
20 }
21
22 // PR c++/30566
23 void h( int x )
24 {
25 class InnerClass
26 {
27 public:
28 static int g( int x ) // { dg-bogus "shadows" }
29 {
30 // empty
31 }
32 };
33 }