p14.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. // RUN: %clang_cc1 -fsyntax-only -verify %s
  2. // expected-no-diagnostics
  3. // C++0x [basic.lookup.unqual]p14:
  4. // If a variable member of a namespace is defined outside of the
  5. // scope of its namespace then any name used in the definition of
  6. // the variable member (after the declarator-id) is looked up as if
  7. // the definition of the variable member occurred in its namespace.
  8. namespace N {
  9. struct S {};
  10. S i;
  11. extern S j;
  12. extern S j2;
  13. }
  14. int i = 2;
  15. N::S N::j = i;
  16. N::S N::j2(i);
  17. // <rdar://problem/13317030>
  18. namespace M {
  19. class X { };
  20. inline X operator-(int, X);
  21. template<typename T>
  22. class Y { };
  23. typedef Y<float> YFloat;
  24. namespace yfloat {
  25. YFloat operator-(YFloat, YFloat);
  26. }
  27. using namespace yfloat;
  28. }
  29. using namespace M;
  30. namespace M {
  31. class Other {
  32. void foo(YFloat a, YFloat b);
  33. };
  34. }
  35. void Other::foo(YFloat a, YFloat b) {
  36. YFloat c = a - b;
  37. }
  38. // <rdar://problem/13540899>
  39. namespace Other {
  40. void other_foo();
  41. }
  42. namespace M2 {
  43. using namespace Other;
  44. extern "C" {
  45. namespace MInner {
  46. extern "C" {
  47. class Bar {
  48. void bar();
  49. };
  50. }
  51. }
  52. }
  53. }
  54. void M2::MInner::Bar::bar() {
  55. other_foo();
  56. }