OSDN Git Service

gcc/cp/
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / g++.dg / warn / Wshadow-6.C
1 // Test the declaration of nested lambda function shadows
2 // a parameter or previous local.
3 // { dg-do compile }
4 // { dg-options "-std=c++0x -Wshadow" }
5
6 struct S {};
7 int f1(int x)   // { dg-warning "shadowed declaration" }
8 {
9  int t = 0;
10  int m = 0;     // { dg-warning "shadowed declaration" }
11  [&t] (int x) { // { dg-warning "shadows a parameter" }
12    int m = 1;   // { dg-warning "shadows a previous local" }
13    t = t + x + m;
14  };
15  return t;
16 }
17
18 void f2(struct S i, int j) {
19   struct A {
20     struct S x;
21     void g(struct S i) { // { dg-warning "shadowed declaration" }
22           struct S x;    // { dg-warning "shadows a member of" }
23           struct S y;    // { dg-warning "shadowed declaration" }
24           int t;
25            [&t](struct S i){   // { dg-warning "shadows a parameter" }
26                  int j = 1;    // { dg-bogus "shadows" }
27                  struct S y;   // { dg-warning "shadows a previous local" }
28                  t = j;
29            };
30     }
31   };
32 }
33
34 void f3(int i) {
35  [=]{
36    int j = i;
37    int i; // { dg-warning "shadows a member of" }
38  };
39 }