p14.cpp revision 6bed88e9d25fd7e16edf3d95447ba414d9d73d72
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
10namespace N {
11  struct S {};
12  S i;
13  extern S j;
14  extern S j2;
15}
16
17int i = 2;
18N::S N::j = i;
19N::S N::j2(i);
20
21// <rdar://problem/13317030>
22namespace 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
37using namespace M;
38
39namespace M {
40
41class Other {
42  void foo(YFloat a, YFloat b);
43};
44
45}
46
47void Other::foo(YFloat a, YFloat b) {
48  YFloat c = a - b;
49}
50