Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CXX / dcl.dcl / basic.namespace / namespace.udecl / p1.cpp
blob021c25016c93f13799f0a757d6a320f3a5619577
1 // RUN: %clang_cc1 -fsyntax-only -verify %s
2 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
3 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
5 // We have to avoid ADL for this test.
7 template <unsigned N> class test {};
9 class foo {}; // expected-note {{candidate constructor (the implicit copy constructor) not viable}}
10 #if __cplusplus >= 201103L // C++11 or later
11 // expected-note@-2 {{candidate constructor (the implicit move constructor) not viable}}
12 #endif
13 test<0> foo(foo); // expected-note {{candidate}}
15 namespace Test0 {
16 class foo { int x; };
17 test<1> foo(class foo);
19 namespace A {
20 test<2> foo(class ::foo); // expected-note {{candidate}} \
21 // expected-note{{passing argument to parameter here}}
23 void test0() {
24 using ::foo;
26 class foo a;
27 test<0> _ = (foo)(a);
30 void test1() {
31 using Test0::foo;
33 class foo a;
34 test<1> _ = (foo)(a);
37 void test2() {
38 class ::foo a;
40 // Argument-dependent lookup is ambiguous between B:: and ::.
41 test<0> _0 = foo(a); // expected-error {{call to 'foo' is ambiguous}}
43 // But basic unqualified lookup is not.
44 test<2> _1 = (foo)(a);
46 class Test0::foo b;
47 test<2> _2 = (foo)(b); // expected-error {{no viable conversion from 'class Test0::foo' to 'class ::foo'}}
52 namespace Test1 {
53 namespace A {
54 class a {};
57 namespace B {
58 typedef class {} b;
61 namespace C {
62 int c(); // expected-note {{target of using declaration}}
65 namespace D {
66 using typename A::a;
67 using typename B::b;
68 using typename C::c; // expected-error {{'typename' keyword used on a non-type}}
70 a _1 = A::a();
71 b _2 = B::b();
75 namespace test2 {
76 class A {
77 protected:
78 operator int();
79 operator bool();
82 class B : private A {
83 protected:
84 using A::operator int; // expected-note {{declared protected here}}
85 public:
86 using A::operator bool;
89 int test() {
90 bool b = B();
91 return B(); // expected-error {{'operator int' is a protected member of 'test2::B'}}
95 namespace test3 {
96 class A {
97 public:
98 ~A();
101 class B {
102 friend class C;
103 private:
104 operator A*();
107 class C : public B {
108 public:
109 using B::operator A*;
112 void test() {
113 delete C();