p1.cpp 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. // RUN: %clang_cc1 -fsyntax-only -verify %s
  2. struct S
  3. {
  4. static int v1; // expected-note{{previous declaration is here}}
  5. int v1; //expected-error{{duplicate member 'v1'}}
  6. int v; //expected-note 2{{previous definition is here}} \
  7. // expected-note{{previous declaration is here}}
  8. static int v; //expected-error{{redefinition of 'v' as different kind of symbol}}
  9. int v; //expected-error{{duplicate member 'v'}}
  10. static int v; //expected-error{{redefinition of 'v' as different kind of symbol}}
  11. enum EnumT { E = 10 };
  12. friend struct M;
  13. struct X; //expected-note{{forward declaration of 'S::X'}}
  14. friend struct X;
  15. };
  16. S::EnumT Evar = S::E; // ok
  17. S::EnumT Evar2 = EnumT(); //expected-error{{use of undeclared identifier 'EnumT'}}
  18. S::M m; //expected-error{{no type named 'M' in 'S'}}
  19. S::X x; //expected-error{{variable has incomplete type 'S::X'}}
  20. struct S2
  21. {
  22. static int v2; // expected-note{{previous declaration is here}}
  23. static int v2; //expected-error{{duplicate member 'v2'}}
  24. };
  25. struct S3
  26. {
  27. static int v3;
  28. struct S4
  29. {
  30. static int v3;
  31. };
  32. };
  33. struct S4
  34. {
  35. static int v4;
  36. };
  37. int S4::v4; //expected-note{{previous definition is here}}
  38. int S4::v4; //expected-error{{redefinition of 'v4'}}
  39. struct S5
  40. {
  41. static int v5; //expected-note{{previous definition is here}}
  42. void v5() { } //expected-error{{redefinition of 'v5' as different kind of symbol}}
  43. void v6() { } //expected-note{{previous definition is here}}
  44. static int v6; //expected-error{{redefinition of 'v6' as different kind of symbol}}
  45. void v7() { }
  46. void v7(int) { } //expected-note{{previous definition is here}}
  47. static int v7; //expected-error{{redefinition of 'v7' as different kind of symbol}}
  48. void v8();
  49. int v8(int); //expected-note{{previous declaration is here}}
  50. int v8; //expected-error{{duplicate member 'v8'}}
  51. };
  52. namespace PR8245 {
  53. class X {
  54. public:
  55. template<class C>
  56. class Inner {
  57. public:
  58. void foo(bool bar = true);
  59. int bam;
  60. };
  61. Inner<int> _foo;
  62. };
  63. void f() {
  64. X::Inner<int> c2i;
  65. X::Inner<float> c2f;
  66. c2i.foo();
  67. c2f.foo();
  68. }
  69. class Y {
  70. class Inner {
  71. void foo(int = sizeof(Y));
  72. };
  73. };
  74. }