1f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
2f4a2713aSLionel Sambuc
3f4a2713aSLionel Sambuc // The nested-name-specifier of a qualified declarator-id shall not begin with a decltype-specifier.
4f4a2713aSLionel Sambuc class foo {
5f4a2713aSLionel Sambuc static int i;
6f4a2713aSLionel Sambuc void func();
7f4a2713aSLionel Sambuc };
8f4a2713aSLionel Sambuc
9f4a2713aSLionel Sambuc int decltype(foo())::i; // expected-error{{'decltype' cannot be used to name a declaration}}
foo()10f4a2713aSLionel Sambuc void decltype(foo())::func() { // expected-error{{'decltype' cannot be used to name a declaration}}
11f4a2713aSLionel Sambuc }
12f4a2713aSLionel Sambuc
13f4a2713aSLionel Sambuc
14f4a2713aSLionel Sambuc template<typename T>
15f4a2713aSLionel Sambuc class tfoo {
16f4a2713aSLionel Sambuc static int i;
17f4a2713aSLionel Sambuc void func();
18f4a2713aSLionel Sambuc };
19f4a2713aSLionel Sambuc
20f4a2713aSLionel Sambuc template<typename T>
21f4a2713aSLionel Sambuc int decltype(tfoo<T>())::i; // expected-error{{nested name specifier 'decltype(tfoo<T>())::' for declaration does not refer into a class, class template or class template partial specialization}}
22f4a2713aSLionel Sambuc template<typename T>
func()23f4a2713aSLionel Sambuc void decltype(tfoo<T>())::func() { // expected-error{{nested name specifier 'decltype(tfoo<T>())::' for declaration does not refer into a class, class template or class template partial specialization}}
24f4a2713aSLionel Sambuc }
25*0a6a1f1dSLionel Sambuc
26*0a6a1f1dSLionel Sambuc // An init-declarator named with a qualified-id can refer to an element of the
27*0a6a1f1dSLionel Sambuc // inline namespace set of the named namespace.
28*0a6a1f1dSLionel Sambuc namespace inline_namespaces {
29*0a6a1f1dSLionel Sambuc namespace N {
30*0a6a1f1dSLionel Sambuc inline namespace M {
31*0a6a1f1dSLionel Sambuc void f(); // expected-note {{possible target}}
32*0a6a1f1dSLionel Sambuc void g();
33*0a6a1f1dSLionel Sambuc extern int m; // expected-note {{candidate}}
34*0a6a1f1dSLionel Sambuc extern int n;
35*0a6a1f1dSLionel Sambuc struct S; // expected-note {{candidate}}
36*0a6a1f1dSLionel Sambuc struct T;
37*0a6a1f1dSLionel Sambuc enum E : int; // expected-note {{candidate}}
38*0a6a1f1dSLionel Sambuc enum F : int;
39*0a6a1f1dSLionel Sambuc template<typename T> void ft(); // expected-note {{here}}
40*0a6a1f1dSLionel Sambuc template<typename T> void gt(); // expected-note {{here}}
41*0a6a1f1dSLionel Sambuc template<typename T> extern int mt; // expected-note {{here}} expected-warning {{extension}}
42*0a6a1f1dSLionel Sambuc template<typename T> extern int nt; // expected-note {{here}} expected-warning {{extension}}
43*0a6a1f1dSLionel Sambuc template<typename T> struct U; // expected-note {{here}}
44*0a6a1f1dSLionel Sambuc template<typename T> struct V; // expected-note {{here}}
45*0a6a1f1dSLionel Sambuc }
46*0a6a1f1dSLionel Sambuc
47*0a6a1f1dSLionel Sambuc // When named by unqualified-id, we do *not* look in the inline namespace
48*0a6a1f1dSLionel Sambuc // set.
f()49*0a6a1f1dSLionel Sambuc void f() {} // expected-note {{possible target}}
50*0a6a1f1dSLionel Sambuc int m; // expected-note {{candidate}}
51*0a6a1f1dSLionel Sambuc struct S {}; // expected-note {{candidate}}
52*0a6a1f1dSLionel Sambuc enum E : int {}; // expected-note {{candidate}}
53*0a6a1f1dSLionel Sambuc
54*0a6a1f1dSLionel Sambuc static_assert(&f != &M::f, ""); // expected-error {{reference to overloaded function could not be resolved}}
55*0a6a1f1dSLionel Sambuc static_assert(&m != &M::m, ""); // expected-error {{ambiguous}}
56*0a6a1f1dSLionel Sambuc typedef S X; // expected-error {{ambiguous}}
57*0a6a1f1dSLionel Sambuc typedef E Y; // expected-error {{ambiguous}}
58*0a6a1f1dSLionel Sambuc
59*0a6a1f1dSLionel Sambuc // When named by (unqualified) template-id, we do look in the inline
60*0a6a1f1dSLionel Sambuc // namespace set. See [namespace.def]p8, [temp.explicit]p3,
61*0a6a1f1dSLionel Sambuc // [temp.expl.spec]p2.
62*0a6a1f1dSLionel Sambuc //
63*0a6a1f1dSLionel Sambuc // This is not explicitly specified for partial specializations, but
64*0a6a1f1dSLionel Sambuc // that is just a language defect.
ft()65*0a6a1f1dSLionel Sambuc template<> void ft<int>() {}
66*0a6a1f1dSLionel Sambuc template void ft<char>(); // expected-error {{undefined}}
67*0a6a1f1dSLionel Sambuc
68*0a6a1f1dSLionel Sambuc template<typename T> int mt<T*>;
69*0a6a1f1dSLionel Sambuc template<> int mt<int>;
70*0a6a1f1dSLionel Sambuc template int mt<int*>;
71*0a6a1f1dSLionel Sambuc template int mt<char>; // expected-error {{undefined}}
72*0a6a1f1dSLionel Sambuc
73*0a6a1f1dSLionel Sambuc template<typename T> struct U<T*> {};
74*0a6a1f1dSLionel Sambuc template<> struct U<int> {};
75*0a6a1f1dSLionel Sambuc template struct U<int*>;
76*0a6a1f1dSLionel Sambuc template struct U<char>; // expected-error {{undefined}}
77*0a6a1f1dSLionel Sambuc }
78*0a6a1f1dSLionel Sambuc
79*0a6a1f1dSLionel Sambuc // When named by qualified-id, we *do* look in the inline namespace set.
g()80*0a6a1f1dSLionel Sambuc void N::g() {}
81*0a6a1f1dSLionel Sambuc int N::n;
82*0a6a1f1dSLionel Sambuc struct N::T {};
83*0a6a1f1dSLionel Sambuc enum N::F : int {};
84*0a6a1f1dSLionel Sambuc
85*0a6a1f1dSLionel Sambuc static_assert(&N::g == &N::M::g, "");
86*0a6a1f1dSLionel Sambuc static_assert(&N::n == &N::M::n, "");
87*0a6a1f1dSLionel Sambuc typedef N::T X;
88*0a6a1f1dSLionel Sambuc typedef N::M::T X;
89*0a6a1f1dSLionel Sambuc typedef N::F Y;
90*0a6a1f1dSLionel Sambuc typedef N::M::F Y;
91*0a6a1f1dSLionel Sambuc
gt()92*0a6a1f1dSLionel Sambuc template<> void N::gt<int>() {}
93*0a6a1f1dSLionel Sambuc template void N::gt<char>(); // expected-error {{undefined}}
94*0a6a1f1dSLionel Sambuc
95*0a6a1f1dSLionel Sambuc template<typename T> int N::nt<T*>;
96*0a6a1f1dSLionel Sambuc template<> int N::nt<int>;
97*0a6a1f1dSLionel Sambuc template int N::nt<int*>;
98*0a6a1f1dSLionel Sambuc template int N::nt<char>; // expected-error {{undefined}}
99*0a6a1f1dSLionel Sambuc
100*0a6a1f1dSLionel Sambuc template<typename T> struct N::V<T*> {};
101*0a6a1f1dSLionel Sambuc template<> struct N::V<int> {};
102*0a6a1f1dSLionel Sambuc template struct N::V<int*>;
103*0a6a1f1dSLionel Sambuc template struct N::V<char>; // expected-error {{undefined}}
104*0a6a1f1dSLionel Sambuc }
105