Welcome to mirror list, hosted at ThFree Co, Russian Federation.

warn-shadow.cpp « SemaCXX « test « clang - github.com/llvm/llvm-project.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3bf9af414db079be07c417ec8967f931e558cd94 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// 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'}}
  }
};

// TODO: this should warn, <rdar://problem/5018057>
class B : A {
  int data;
  static int field;
};

// rdar://8900456
namespace rdar8900456 {
struct Foo {
  static void Baz();
private:
  int Bar;
};

void Foo::Baz() {
  double Bar = 12; // Don't warn.
}
}

// http://llvm.org/PR9160
namespace PR9160 {
struct V {
  V(int);
};
struct S {
  V v;
  static void m() {
    if (1) {
      V v(0);
    }
  }
};
}