brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.8 KiB · b19c81f Raw
151 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -verify %s2 3namespace N {4  struct X { };5  6  X operator+(X, X);7 8  void f(X); // expected-note 2 {{'N::f' declared here}}9  void g(X); // expected-note{{candidate function}}10 11  void test_multiadd(X x) {12    (void)(x + x);13  }14}15 16namespace M {17  struct Y : N::X { };18}19 20void f();21 22void test_operator_adl(N::X x, M::Y y) {23  (void)(x + x);24  (void)(y + y);25}26 27void 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'?}}32}33 34namespace N {35  void test_multiadd2(X x) {36    (void)(x + x);37  }38}39 40 41void test_func_adl_only(N::X x) {42  g(x);43}44 45namespace M {46  int g(N::X); // expected-note{{candidate function}}47 48  void test(N::X x) {49    g(x); // expected-error{{call to 'g' is ambiguous}}50    int i = (g)(x);51 52    int g(N::X);53    g(x); // okay; calls locally-declared function, no ADL54  }55}56 57 58void test_operator_name_adl(N::X x) {59  (void)operator+(x, x);60}61 62struct Z { };63int& f(Z);64 65namespace O {66  char &f();67  void test_global_scope_adl(Z z) {68    {69      int& ir = f(z);70    }71  }72}73 74extern "C" {75  struct L { int x; };76}77 78void h(L); // expected-note{{candidate function}}79 80namespace P {81  void h(L); // expected-note{{candidate function}}82  void test_transparent_context_adl(L l) {83    {84      h(l); // expected-error {{call to 'h' is ambiguous}}85    }86  }87}88 89namespace test5 {90  namespace NS {91    struct A;92    void foo(void (*)(A&));93  }94  void bar(NS::A& a);95 96  void test() {97    foo(&bar);98  }99}100 101// PR6762: __builtin_va_list should be invisible to ADL on all platforms.102void test6_function(__builtin_va_list &argv);103namespace test6 {104  void test6_function(__builtin_va_list &argv);105 106  void test() {107    __builtin_va_list args;108    test6_function(args);109  }110}111 112// PR13682: we might need to instantiate class temploids.113namespace test7 {114  namespace inner {115    class A {};116    void test7_function(A &);117  }118  template <class T> class B : public inner::A {};119 120  void test(B<int> &ref) {121    test7_function(ref);122  }123}124 125// Like test7, but ensure we don't complain if the type is properly126// incomplete.127namespace test8 {128  template <class T> class B;129  void test8_function(B<int> &);130 131  void test(B<int> &ref) {132    test8_function(ref);133  }134}135 136 137 138// [...] Typedef names and using-declarations used to specify the types139// do not contribute to this set.140namespace 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);    // ok147    g1(s);   // expected-error {{use of undeclared}}148    g2(s);   // expected-error {{use of undeclared}}149  }150}151