Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CXX / basic / basic.lookup / basic.lookup.argdep / p2.cpp
blobb19c81f2f333821812672def0c4450b69dbda7c2
1 // RUN: %clang_cc1 -fsyntax-only -verify %s
3 namespace N {
4 struct X { };
6 X operator+(X, X);
8 void f(X); // expected-note 2 {{'N::f' declared here}}
9 void g(X); // expected-note{{candidate function}}
11 void test_multiadd(X x) {
12 (void)(x + x);
16 namespace M {
17 struct Y : N::X { };
20 void f();
22 void test_operator_adl(N::X x, M::Y y) {
23 (void)(x + x);
24 (void)(y + y);
27 void test_func_adl(N::X x, M::Y y) {
28 f(x);
29 f(y);
30 (f)(x); // expected-error{{too many arguments to function call, expected 0, have 1; did you mean 'N::f'?}}
31 ::f(x); // expected-error{{too many arguments to function call, expected 0, have 1; did you mean 'N::f'?}}
34 namespace N {
35 void test_multiadd2(X x) {
36 (void)(x + x);
41 void test_func_adl_only(N::X x) {
42 g(x);
45 namespace M {
46 int g(N::X); // expected-note{{candidate function}}
48 void test(N::X x) {
49 g(x); // expected-error{{call to 'g' is ambiguous}}
50 int i = (g)(x);
52 int g(N::X);
53 g(x); // okay; calls locally-declared function, no ADL
58 void test_operator_name_adl(N::X x) {
59 (void)operator+(x, x);
62 struct Z { };
63 int& f(Z);
65 namespace O {
66 char &f();
67 void test_global_scope_adl(Z z) {
69 int& ir = f(z);
74 extern "C" {
75 struct L { int x; };
78 void h(L); // expected-note{{candidate function}}
80 namespace P {
81 void h(L); // expected-note{{candidate function}}
82 void test_transparent_context_adl(L l) {
84 h(l); // expected-error {{call to 'h' is ambiguous}}
89 namespace test5 {
90 namespace NS {
91 struct A;
92 void foo(void (*)(A&));
94 void bar(NS::A& a);
96 void test() {
97 foo(&bar);
101 // PR6762: __builtin_va_list should be invisible to ADL on all platforms.
102 void test6_function(__builtin_va_list &argv);
103 namespace test6 {
104 void test6_function(__builtin_va_list &argv);
106 void test() {
107 __builtin_va_list args;
108 test6_function(args);
112 // PR13682: we might need to instantiate class temploids.
113 namespace test7 {
114 namespace inner {
115 class A {};
116 void test7_function(A &);
118 template <class T> class B : public inner::A {};
120 void test(B<int> &ref) {
121 test7_function(ref);
125 // Like test7, but ensure we don't complain if the type is properly
126 // incomplete.
127 namespace test8 {
128 template <class T> class B;
129 void test8_function(B<int> &);
131 void test(B<int> &ref) {
132 test8_function(ref);
138 // [...] Typedef names and using-declarations used to specify the types
139 // do not contribute to this set.
140 namespace typedef_names_and_using_declarations {
141 namespace N { struct S {}; void f(S); }
142 namespace M { typedef N::S S; void g1(S); } // expected-note {{declared here}}
143 namespace L { using N::S; void g2(S); } // expected-note {{declared here}}
144 void test() {
145 M::S s;
146 f(s); // ok
147 g1(s); // expected-error {{use of undeclared}}
148 g2(s); // expected-error {{use of undeclared}}