xref: /llvm-project/clang/test/CXX/basic/basic.lookup/basic.lookup.unqual/p14.cpp (revision 0f1c1be1968076d6f96f8a7bcc4a15cf195ecd97)
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 namespace M {
22   class X { };
23   inline X operator-(int, X);
24 
25   template<typename T>
26   class Y { };
27 
28   typedef Y<float> YFloat;
29 
30   namespace yfloat {
31     YFloat operator-(YFloat, YFloat);
32   }
33   using namespace yfloat;
34 }
35 
36 using namespace M;
37 
38 namespace M {
39 
40 class Other {
41   void foo(YFloat a, YFloat b);
42 };
43 
44 }
45 
foo(YFloat a,YFloat b)46 void Other::foo(YFloat a, YFloat b) {
47   YFloat c = a - b;
48 }
49 
50 namespace Other {
51   void other_foo();
52 }
53 
54 namespace M2 {
55   using namespace Other;
56 
57   extern "C" {
58     namespace MInner {
59       extern "C" {
60         class Bar {
61           void bar();
62         };
63       }
64     }
65   }
66 }
67 
bar()68 void M2::MInner::Bar::bar() {
69   other_foo();
70 }
71