55 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s2 3namespace bullet2 {4 5// For non-member candidates, if no operand has a class type, only those6// non-member functions that have a matching enumeration parameter are7// candidates.8 9struct B { template<typename T> B(T); };10int operator~(B);11template<typename T> int operator%(B, T);12enum class E { e };13 14template<typename T> int f(T t) { return ~t; } // expected-error {{invalid argument type}}15template<typename T, typename U> int f(T t, U u) { return t % u; } // expected-error {{invalid operands to}}16 // expected-note@-1 {{no implicit conversion for scoped enum}}17 18int b1 = ~E::e; // expected-error {{invalid argument type}}19int b2 = f(E::e); // expected-note {{in instantiation of}}20int b3 = f(0, E::e);21int b4 = f(E::e, 0); // expected-note {{in instantiation of}}22 23}24 25namespace bullet3 {26 27// This is specifically testing the bullet:28// "do not have the same parameter-type-list as any non-template29// non-member candidate."30// The rest is sort of hard to test separately.31 32enum E1 { one };33enum E2 { two };34 35struct A;36 37A operator >= (E1, E1);38A operator >= (E1, const E2);39 40E1 a;41E2 b;42 43extern A test1;44extern decltype(a >= a) test1;45extern decltype(a >= b) test1;46 47template <typename T> A operator <= (E1, T);48extern bool test2;49extern decltype(a <= a) test2;50 51extern A test3;52extern decltype(a <= b) test3;53 54}55