1b2eb28ad57b13799403b6b7c30829601974fb18fDouglas Gregor// RUN: %clang_cc1 -fsyntax-only -verify %s
2b2eb28ad57b13799403b6b7c30829601974fb18fDouglas Gregor
3b2eb28ad57b13799403b6b7c30829601974fb18fDouglas Gregorstruct S
4b2eb28ad57b13799403b6b7c30829601974fb18fDouglas Gregor{
5b2eb28ad57b13799403b6b7c30829601974fb18fDouglas Gregor  static int v1; // expected-note{{previous declaration is here}}
6b2eb28ad57b13799403b6b7c30829601974fb18fDouglas Gregor  int v1; //expected-error{{duplicate member 'v1'}}
7b2eb28ad57b13799403b6b7c30829601974fb18fDouglas Gregor  int v;  //expected-note 2{{previous definition is here}} \
8b2eb28ad57b13799403b6b7c30829601974fb18fDouglas Gregor          // expected-note{{previous declaration is here}}
9b2eb28ad57b13799403b6b7c30829601974fb18fDouglas Gregor  static int v; //expected-error{{redefinition of 'v' as different kind of symbol}}
10b2eb28ad57b13799403b6b7c30829601974fb18fDouglas Gregor  int v; //expected-error{{duplicate member 'v'}}
11b2eb28ad57b13799403b6b7c30829601974fb18fDouglas Gregor  static int v; //expected-error{{redefinition of 'v' as different kind of symbol}}
12b2eb28ad57b13799403b6b7c30829601974fb18fDouglas Gregor  enum EnumT { E = 10 };
13b2eb28ad57b13799403b6b7c30829601974fb18fDouglas Gregor  friend struct M;
14b2eb28ad57b13799403b6b7c30829601974fb18fDouglas Gregor  struct X;  //expected-note{{forward declaration of 'S::X'}}
15b2eb28ad57b13799403b6b7c30829601974fb18fDouglas Gregor  friend struct X;
16b2eb28ad57b13799403b6b7c30829601974fb18fDouglas Gregor};
17b2eb28ad57b13799403b6b7c30829601974fb18fDouglas Gregor
18b2eb28ad57b13799403b6b7c30829601974fb18fDouglas GregorS::EnumT Evar = S::E; // ok
19b2eb28ad57b13799403b6b7c30829601974fb18fDouglas GregorS::EnumT Evar2 = EnumT(); //expected-error{{use of undeclared identifier 'EnumT'}}
20b2eb28ad57b13799403b6b7c30829601974fb18fDouglas GregorS::M m; //expected-error{{no type named 'M' in 'S'}}
21b2eb28ad57b13799403b6b7c30829601974fb18fDouglas GregorS::X x; //expected-error{{variable has incomplete type 'S::X'}}
22b2eb28ad57b13799403b6b7c30829601974fb18fDouglas Gregor
23b2eb28ad57b13799403b6b7c30829601974fb18fDouglas Gregor
24b2eb28ad57b13799403b6b7c30829601974fb18fDouglas Gregorstruct S2
25b2eb28ad57b13799403b6b7c30829601974fb18fDouglas Gregor{
26b2eb28ad57b13799403b6b7c30829601974fb18fDouglas Gregor  static int v2; // expected-note{{previous declaration is here}}
27b2eb28ad57b13799403b6b7c30829601974fb18fDouglas Gregor  static int v2; //expected-error{{duplicate member 'v2'}}
28b2eb28ad57b13799403b6b7c30829601974fb18fDouglas Gregor};
29b2eb28ad57b13799403b6b7c30829601974fb18fDouglas Gregor
30b2eb28ad57b13799403b6b7c30829601974fb18fDouglas Gregorstruct S3
31b2eb28ad57b13799403b6b7c30829601974fb18fDouglas Gregor{
32b2eb28ad57b13799403b6b7c30829601974fb18fDouglas Gregor  static int v3;
33b2eb28ad57b13799403b6b7c30829601974fb18fDouglas Gregor  struct S4
34b2eb28ad57b13799403b6b7c30829601974fb18fDouglas Gregor  {
35b2eb28ad57b13799403b6b7c30829601974fb18fDouglas Gregor    static int v3;
36b2eb28ad57b13799403b6b7c30829601974fb18fDouglas Gregor  };
37b2eb28ad57b13799403b6b7c30829601974fb18fDouglas Gregor};
38b2eb28ad57b13799403b6b7c30829601974fb18fDouglas Gregor
39b2eb28ad57b13799403b6b7c30829601974fb18fDouglas Gregorstruct S4
40b2eb28ad57b13799403b6b7c30829601974fb18fDouglas Gregor{
41b2eb28ad57b13799403b6b7c30829601974fb18fDouglas Gregor  static int v4;
42b2eb28ad57b13799403b6b7c30829601974fb18fDouglas Gregor};
43b2eb28ad57b13799403b6b7c30829601974fb18fDouglas Gregor
44b2eb28ad57b13799403b6b7c30829601974fb18fDouglas Gregorint S4::v4; //expected-note{{previous definition is here}}
45b2eb28ad57b13799403b6b7c30829601974fb18fDouglas Gregorint S4::v4; //expected-error{{redefinition of 'v4'}}
46b2eb28ad57b13799403b6b7c30829601974fb18fDouglas Gregor
47b2eb28ad57b13799403b6b7c30829601974fb18fDouglas Gregorstruct S5
48b2eb28ad57b13799403b6b7c30829601974fb18fDouglas Gregor{
49b2eb28ad57b13799403b6b7c30829601974fb18fDouglas Gregor  static int v5; //expected-note{{previous definition is here}}
50b2eb28ad57b13799403b6b7c30829601974fb18fDouglas Gregor  void v5() { } //expected-error{{redefinition of 'v5' as different kind of symbol}}
51b2eb28ad57b13799403b6b7c30829601974fb18fDouglas Gregor
52b2eb28ad57b13799403b6b7c30829601974fb18fDouglas Gregor  void v6() { } //expected-note{{previous definition is here}}
53b2eb28ad57b13799403b6b7c30829601974fb18fDouglas Gregor  static int v6; //expected-error{{redefinition of 'v6' as different kind of symbol}}
54b2eb28ad57b13799403b6b7c30829601974fb18fDouglas Gregor
55b2eb28ad57b13799403b6b7c30829601974fb18fDouglas Gregor  void v7() { }
56b2eb28ad57b13799403b6b7c30829601974fb18fDouglas Gregor  void v7(int) { } //expected-note{{previous definition is here}}
57b2eb28ad57b13799403b6b7c30829601974fb18fDouglas Gregor  static int v7;  //expected-error{{redefinition of 'v7' as different kind of symbol}}
58b2eb28ad57b13799403b6b7c30829601974fb18fDouglas Gregor
59b2eb28ad57b13799403b6b7c30829601974fb18fDouglas Gregor  void v8();
60b2eb28ad57b13799403b6b7c30829601974fb18fDouglas Gregor  int v8(int); //expected-note{{previous declaration is here}}
61b2eb28ad57b13799403b6b7c30829601974fb18fDouglas Gregor  int v8; //expected-error{{duplicate member 'v8'}}
62b2eb28ad57b13799403b6b7c30829601974fb18fDouglas Gregor
63b2eb28ad57b13799403b6b7c30829601974fb18fDouglas Gregor
64b2eb28ad57b13799403b6b7c30829601974fb18fDouglas Gregor};
653012d21880276c87377e9cee335f5c6a15e0000dDouglas Gregor
663012d21880276c87377e9cee335f5c6a15e0000dDouglas Gregornamespace PR8245 {
673012d21880276c87377e9cee335f5c6a15e0000dDouglas Gregor  class X {
683012d21880276c87377e9cee335f5c6a15e0000dDouglas Gregor  public:
693012d21880276c87377e9cee335f5c6a15e0000dDouglas Gregor    template<class C>
703012d21880276c87377e9cee335f5c6a15e0000dDouglas Gregor    class Inner {
713012d21880276c87377e9cee335f5c6a15e0000dDouglas Gregor    public:
723012d21880276c87377e9cee335f5c6a15e0000dDouglas Gregor      void foo(bool bar = true);
733012d21880276c87377e9cee335f5c6a15e0000dDouglas Gregor      int bam;
743012d21880276c87377e9cee335f5c6a15e0000dDouglas Gregor    };
753012d21880276c87377e9cee335f5c6a15e0000dDouglas Gregor
763012d21880276c87377e9cee335f5c6a15e0000dDouglas Gregor    Inner<int> _foo;
773012d21880276c87377e9cee335f5c6a15e0000dDouglas Gregor  };
783012d21880276c87377e9cee335f5c6a15e0000dDouglas Gregor
793012d21880276c87377e9cee335f5c6a15e0000dDouglas Gregor  void f() {
803012d21880276c87377e9cee335f5c6a15e0000dDouglas Gregor    X::Inner<int> c2i;
813012d21880276c87377e9cee335f5c6a15e0000dDouglas Gregor    X::Inner<float> c2f;
823012d21880276c87377e9cee335f5c6a15e0000dDouglas Gregor    c2i.foo();
833012d21880276c87377e9cee335f5c6a15e0000dDouglas Gregor    c2f.foo();
843012d21880276c87377e9cee335f5c6a15e0000dDouglas Gregor  }
853012d21880276c87377e9cee335f5c6a15e0000dDouglas Gregor
863012d21880276c87377e9cee335f5c6a15e0000dDouglas Gregor  class Y {
873012d21880276c87377e9cee335f5c6a15e0000dDouglas Gregor    class Inner {
883012d21880276c87377e9cee335f5c6a15e0000dDouglas Gregor      void foo(int = sizeof(Y));
893012d21880276c87377e9cee335f5c6a15e0000dDouglas Gregor    };
903012d21880276c87377e9cee335f5c6a15e0000dDouglas Gregor  };
913012d21880276c87377e9cee335f5c6a15e0000dDouglas Gregor}
92