Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / Misc / diag-inline-namespace.cpp
blob34d549bc1cc0b6f44617e1e4d67f02f84bb6e4f5
1 // RUN: %clang_cc1 -verify %s -std=c++20
3 // We avoid printing the name of an inline namespace unless it's necessary to
4 // uniquely identify the target.
5 namespace N {
6 inline namespace A {
7 inline namespace B {
8 inline namespace C {
9 int f, g, h, i, j;
10 struct f; struct g; struct h; struct i; struct j;
12 struct g;
13 struct j;
15 struct h;
17 struct i;
18 struct j;
20 template<int*> struct Q; // expected-note 5{{here}}
21 Q<&A::B::C::f> q1; // expected-error {{implicit instantiation of undefined template 'N::Q<&N::f>'}}
22 Q<&A::B::C::g> q2; // expected-error {{implicit instantiation of undefined template 'N::Q<&N::C::g>'}}
23 Q<&A::B::C::h> q3; // expected-error {{implicit instantiation of undefined template 'N::Q<&N::B::h>'}}
24 Q<&A::B::C::i> q4; // expected-error {{implicit instantiation of undefined template 'N::Q<&N::A::i>'}}
25 Q<&A::B::C::j> q5; // expected-error {{implicit instantiation of undefined template 'N::Q<&N::C::j>'}}
27 template<typename> struct R; // expected-note 5{{here}}
28 R<struct A::B::C::f> r1; // expected-error {{implicit instantiation of undefined template 'N::R<N::f>'}}
29 R<struct A::B::C::g> r2; // expected-error {{implicit instantiation of undefined template 'N::R<N::C::g>'}}
30 R<struct A::B::C::h> r3; // expected-error {{implicit instantiation of undefined template 'N::R<N::B::h>'}}
31 R<struct A::B::C::i> r4; // expected-error {{implicit instantiation of undefined template 'N::R<N::A::i>'}}
32 R<struct A::B::C::j> r5; // expected-error {{implicit instantiation of undefined template 'N::R<N::C::j>'}}
34 // Make the name N::C ambiguous.
35 inline namespace A { int C; }
37 template<int*> struct S; // expected-note 5{{here}}
38 S<&A::B::C::f> s1; // expected-error {{implicit instantiation of undefined template 'N::S<&N::f>'}}
39 S<&A::B::C::g> s2; // expected-error {{implicit instantiation of undefined template 'N::S<&N::B::C::g>'}}
40 S<&A::B::C::h> s3; // expected-error {{implicit instantiation of undefined template 'N::S<&N::B::h>'}}
41 S<&A::B::C::i> s4; // expected-error {{implicit instantiation of undefined template 'N::S<&N::A::i>'}}
42 S<&A::B::C::j> s5; // expected-error {{implicit instantiation of undefined template 'N::S<&N::B::C::j>'}}
44 template<typename> struct T; // expected-note 5{{here}}
45 T<struct A::B::C::f> t1; // expected-error {{implicit instantiation of undefined template 'N::T<N::f>'}}
46 T<struct A::B::C::g> t2; // expected-error {{implicit instantiation of undefined template 'N::T<N::B::C::g>'}}
47 T<struct A::B::C::h> t3; // expected-error {{implicit instantiation of undefined template 'N::T<N::B::h>'}}
48 T<struct A::B::C::i> t4; // expected-error {{implicit instantiation of undefined template 'N::T<N::A::i>'}}
49 T<struct A::B::C::j> t5; // expected-error {{implicit instantiation of undefined template 'N::T<N::B::C::j>'}}
52 namespace dont_crash {
53 // A malformed lookup involving inline namespaces in a linkage specification
54 // would previous cause an assertion due to the way diagnostics are emitted.
55 extern "C++" inline namespace {
56 namespace a {
57 a : b // expected-error {{unexpected ':' in nested name specifier; did you mean '::'?}} \
58 // expected-error {{no type named 'b' in namespace 'dont_crash::a'}}
59 } // expected-error {{expected unqualified-id}}
60 } // inline namespace
61 } // dont_crash