1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s 2*f4a2713aSLionel Sambuc 3*f4a2713aSLionel Sambuc namespace std { 4*f4a2713aSLionel Sambuc class type_info {}; 5*f4a2713aSLionel Sambuc } 6*f4a2713aSLionel Sambuc 7*f4a2713aSLionel Sambuc void one() { } 8*f4a2713aSLionel Sambuc void two() { } // expected-note 4{{possible target for call}} 9*f4a2713aSLionel Sambuc void two(int) { } // expected-note 4{{possible target for call}} 10*f4a2713aSLionel Sambuc 11*f4a2713aSLionel Sambuc template<class T> void twoT() { } // expected-note 5{{possible target for call}} 12*f4a2713aSLionel Sambuc template<class T> void twoT(int) { } // expected-note 5{{possible target for call}} 13*f4a2713aSLionel Sambuc 14*f4a2713aSLionel Sambuc template<class T> void oneT() { } 15*f4a2713aSLionel Sambuc template<class T, class U> void oneT(U) { } 16*f4a2713aSLionel Sambuc /* 17*f4a2713aSLionel Sambuc The target can be 18*f4a2713aSLionel Sambuc an object or reference being initialized (8.5, 8.5.3), 19*f4a2713aSLionel Sambuc the left side of an assignment (5.17), 20*f4a2713aSLionel Sambuc a parameter of a function (5.2.2), 21*f4a2713aSLionel Sambuc a parameter of a user-defined operator (13.5), 22*f4a2713aSLionel Sambuc the return value of a function, operator function, or conversion (6.6.3), 23*f4a2713aSLionel Sambuc an explicit type conversion (5.2.3, 5.2.9, 5.4), or 24*f4a2713aSLionel Sambuc a non-type template-parameter (14.3.2) 25*f4a2713aSLionel Sambuc */ 26*f4a2713aSLionel Sambuc //#include <typeinfo> 27*f4a2713aSLionel Sambuc template<void (*p)(int)> struct test { }; 28*f4a2713aSLionel Sambuc 29*f4a2713aSLionel Sambuc int main() 30*f4a2713aSLionel Sambuc { 31*f4a2713aSLionel Sambuc one; // expected-warning {{expression result unused}} 32*f4a2713aSLionel Sambuc two; // expected-error {{reference to overloaded function could not be resolved; did you mean to call it with no arguments?}} 33*f4a2713aSLionel Sambuc oneT<int>; // expected-warning {{expression result unused}} 34*f4a2713aSLionel Sambuc twoT<int>; // expected-error {{reference to overloaded function could not be resolved; did you mean to call it?}} 35*f4a2713aSLionel Sambuc typeid(oneT<int>); // expected-warning{{expression result unused}} 36*f4a2713aSLionel Sambuc sizeof(oneT<int>); // expected-error {{invalid application of 'sizeof' to a function type}} 37*f4a2713aSLionel Sambuc sizeof(twoT<int>); //expected-error {{reference to overloaded function could not be resolved; did you mean to call it?}} 38*f4a2713aSLionel Sambuc decltype(oneT<int>)* fun = 0; 39*f4a2713aSLionel Sambuc 40*f4a2713aSLionel Sambuc *one; // expected-warning {{expression result unused}} 41*f4a2713aSLionel Sambuc *oneT<int>; // expected-warning {{expression result unused}} 42*f4a2713aSLionel Sambuc *two; //expected-error {{reference to overloaded function could not be resolved; did you mean to call it with no arguments?}} expected-error {{indirection requires pointer operand}} 43*f4a2713aSLionel Sambuc *twoT<int>; //expected-error {{reference to overloaded function could not be resolved; did you mean to call it?}} 44*f4a2713aSLionel Sambuc !oneT<int>; // expected-warning {{expression result unused}} expected-warning {{address of function 'oneT<int>' will always evaluate to 'true'}} expected-note {{prefix with the address-of operator to silence this warning}} 45*f4a2713aSLionel Sambuc +oneT<int>; // expected-warning {{expression result unused}} 46*f4a2713aSLionel Sambuc -oneT<int>; //expected-error {{invalid argument type}} 47*f4a2713aSLionel Sambuc oneT<int> == 0; // expected-warning {{equality comparison result unused}} \ 48*f4a2713aSLionel Sambuc // expected-note {{use '=' to turn this equality comparison into an assignment}} 49*f4a2713aSLionel Sambuc 0 == oneT<int>; // expected-warning {{equality comparison result unused}} 50*f4a2713aSLionel Sambuc 0 != oneT<int>; // expected-warning {{inequality comparison result unused}} 51*f4a2713aSLionel Sambuc (false ? one : oneT<int>); // expected-warning {{expression result unused}} 52*f4a2713aSLionel Sambuc void (*p1)(int); p1 = oneT<int>; 53*f4a2713aSLionel Sambuc 54*f4a2713aSLionel Sambuc int i = (int) (false ? (void (*)(int))twoT<int> : oneT<int>); //expected-error {{incompatible operand}} 55*f4a2713aSLionel Sambuc (twoT<int>) == oneT<int>; //expected-error {{reference to overloaded function could not be resolved; did you mean to call it?}} {{cannot resolve overloaded function 'twoT' from context}} 56*f4a2713aSLionel Sambuc bool b = oneT<int>; // expected-warning {{address of function 'oneT<int>' will always evaluate to 'true'}} expected-note {{prefix with the address-of operator to silence this warning}} 57*f4a2713aSLionel Sambuc void (*p)() = oneT<int>; 58*f4a2713aSLionel Sambuc test<oneT<int> > ti; 59*f4a2713aSLionel Sambuc void (*u)(int) = oneT<int>; 60*f4a2713aSLionel Sambuc 61*f4a2713aSLionel Sambuc b = (void (*)()) twoT<int>; 62*f4a2713aSLionel Sambuc 63*f4a2713aSLionel Sambuc one < one; //expected-warning {{self-comparison always evaluates to false}} \ 64*f4a2713aSLionel Sambuc //expected-warning {{expression result unused}} 65*f4a2713aSLionel Sambuc 66*f4a2713aSLionel Sambuc oneT<int> < oneT<int>; //expected-warning {{self-comparison always evaluates to false}} \ 67*f4a2713aSLionel Sambuc //expected-warning {{expression result unused}} 68*f4a2713aSLionel Sambuc 69*f4a2713aSLionel Sambuc two < two; //expected-error 2 {{reference to overloaded function could not be resolved; did you mean to call it with no arguments?}} expected-error {{invalid operands to binary expression ('void' and 'void')}} 70*f4a2713aSLionel Sambuc twoT<int> < twoT<int>; //expected-error {{reference to overloaded function could not be resolved; did you mean to call it?}} {{cannot resolve overloaded function 'twoT' from context}} 71*f4a2713aSLionel Sambuc oneT<int> == 0; // expected-warning {{equality comparison result unused}} \ 72*f4a2713aSLionel Sambuc // expected-note {{use '=' to turn this equality comparison into an assignment}} 73*f4a2713aSLionel Sambuc 74*f4a2713aSLionel Sambuc } 75*f4a2713aSLionel Sambuc 76*f4a2713aSLionel Sambuc struct rdar9108698 { 77*f4a2713aSLionel Sambuc template<typename> void f(); // expected-note{{possible target for call}} 78*f4a2713aSLionel Sambuc }; 79*f4a2713aSLionel Sambuc 80*f4a2713aSLionel Sambuc void test_rdar9108698(rdar9108698 x) { 81*f4a2713aSLionel Sambuc x.f<int>; // expected-error{{reference to non-static member function must be called}} 82*f4a2713aSLionel Sambuc } 83