p2.cpp 989 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // RUN: %clang_cc1 -fsyntax-only -verify %s
  2. namespace test0 {
  3. struct A {
  4. static int foo;
  5. };
  6. namespace i0 {
  7. typedef int A; // expected-note {{declared here}}
  8. int test() {
  9. struct A a; // expected-error {{elaborated type refers to a typedef}}
  10. return a.foo;
  11. }
  12. }
  13. namespace i1 {
  14. template <class> class A; // expected-note {{declared here}}
  15. int test() {
  16. struct A a; // expected-error {{elaborated type refers to a template}}
  17. return a.foo;
  18. }
  19. }
  20. namespace i2 {
  21. int A;
  22. int test() {
  23. struct A a;
  24. return a.foo;
  25. }
  26. }
  27. namespace i3 {
  28. void A();
  29. int test() {
  30. struct A a;
  31. return a.foo;
  32. }
  33. }
  34. namespace i4 {
  35. template <class T> void A();
  36. int test() {
  37. struct A a;
  38. return a.foo;
  39. }
  40. }
  41. // This should magically be okay; see comment in SemaDecl.cpp.
  42. // rdar://problem/7898108
  43. typedef struct A A;
  44. int test() {
  45. struct A a;
  46. return a.foo;
  47. }
  48. }