| 1 |
// RUN: %clang_cc1 -std=c++2a -verify %s |
| 2 |
|
| 3 |
namespace N { |
| 4 |
struct Q {}; |
| 5 |
template<typename> int f(Q); |
| 6 |
template<int> int f(Q); |
| 7 |
template<typename> int g(Q); |
| 8 |
template<int> int g(Q); |
| 9 |
|
| 10 |
template<int> int some_long_name(Q); // expected-note {{here}} |
| 11 |
} |
| 12 |
N::Q q; |
| 13 |
int g(); |
| 14 |
|
| 15 |
int h(); |
| 16 |
template<int> int h(...); |
| 17 |
int h(int); |
| 18 |
|
| 19 |
// OK, these find the above functions by ADL. |
| 20 |
int a = f<int>(q); |
| 21 |
int b(f<int>(q)); |
| 22 |
int c(f<0>(q)); |
| 23 |
int d = g<int>(q); |
| 24 |
|
| 25 |
int e = h<0>(q); // ok, found by unqualified lookup |
| 26 |
|
| 27 |
void fn() { |
| 28 |
f<0>(q); |
| 29 |
int f; |
| 30 |
f<0>(q); // expected-error {{invalid operands to binary expression}} // expected-error {{chained comparison 'X < Y > Z' does not behave the same as a mathematical expression}} |
| 31 |
} |
| 32 |
|
| 33 |
void disambig() { |
| 34 |
// FIXME: It's unclear whether ending the template argument at the > inside the ?: is correct here (see DR579). |
| 35 |
f<true ? 1 > 2 : 3>(q); // expected-error {{expected ':'}} expected-note {{to match}} expected-error {{expected expression}} |
| 36 |
|
| 37 |
f < 1 + 3 > (q); // ok, function call |
| 38 |
} |
| 39 |
|
| 40 |
bool typo(int something) { // expected-note 4{{declared here}} |
| 41 |
// FIXME: We shouldn't suggest the N:: for an ADL call if the candidate can be found by ADL. |
| 42 |
some_logn_name<3>(q); // expected-error {{did you mean 'N::some_long_name'?}} |
| 43 |
somethign < 3 ? h() > 4 : h(0); // expected-error {{did you mean 'something'}} |
| 44 |
// This is parsed as a comparison on the left of a ?: expression. |
| 45 |
somethign < 3 ? h() + 4 : h(0); // expected-error {{did you mean 'something'}} |
| 46 |
// This is parsed as an ADL-only template-id call. |
| 47 |
somethign < 3 ? h() + 4 : h(0) >(0); // expected-error {{undeclared identifier 'somethign'}} |
| 48 |
bool k(somethign < 3); // expected-error {{did you mean 'something'}} |
| 49 |
return somethign < 3; // expected-error {{did you mean 'something'}} |
| 50 |
} |
| 51 |
|
| 52 |
// Ensure that treating undeclared identifiers as template names doesn't cause |
| 53 |
// problems. |
| 54 |
struct W<int> {}; // expected-error {{undeclared template struct 'W'}} |
| 55 |
X<int>::Y xy; // expected-error {{no template named 'X'}} |
| 56 |
void xf(X<int> x); // expected-error {{no template named 'X'}} |
| 57 |
struct A : X<int> { // expected-error {{no template named 'X'}} |
| 58 |
A() : X<int>() {} // expected-error {{no template named 'X'}} |
| 59 |
}; |
| 60 |
|
| 61 |
// Similarly for treating overload sets of functions as template names. |
| 62 |
struct g<int> {}; // expected-error {{'g' refers to a function template}} |
| 63 |
g<int>::Y xy; // expected-error {{no template named 'g'}} FIXME lies |
| 64 |
void xf(g<int> x); // expected-error {{variable has incomplete type 'void'}} expected-error 1+{{}} |
| 65 |
struct B : g<int> { // expected-error {{expected class name}} |
| 66 |
B() : g<int>() {} // expected-error {{expected class member or base class name}} |
| 67 |
}; |
| 68 |
|
| 69 |
namespace vector_components { |
| 70 |
typedef __attribute__((__ext_vector_type__(2))) float vector_float2; |
| 71 |
bool foo123(vector_float2 &A, vector_float2 &B) |
| 72 |
{ |
| 73 |
return A.x < B.x && B.y > A.y; |
| 74 |
} |
| 75 |
} |