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