brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.8 KiB · 1bc7f2c Raw
76 lines · cpp
1// RUN: %clang_cc1 -std=c++2a -verify %s2 3namespace 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}12N::Q q;13int g();14 15int h();16template<int> int h(...);17int h(int);18 19// OK, these find the above functions by ADL.20int a = f<int>(q);21int b(f<int>(q));22int c(f<0>(q));23int d = g<int>(q);24 25int e = h<0>(q); // ok, found by unqualified lookup26 27void 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 33void 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 call38}39 40bool 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 cause53// problems.54struct W<int> {}; // expected-error {{undeclared template struct 'W'}}55X<int>::Y xy; // expected-error {{no template named 'X'}}56void xf(X<int> x); // expected-error {{no template named 'X'}}57struct 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.62struct g<int> {}; // expected-error {{'g' refers to a function template}}63g<int>::Y xy; // expected-error {{no template named 'g'}} FIXME lies64void xf(g<int> x); // expected-error {{variable has incomplete type 'void'}} expected-error 1+{{}}65struct B : g<int> { // expected-error {{expected class name}}66  B() : g<int>() {} // expected-error {{expected class member or base class name}}67};68 69namespace 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}76