diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-05-05 00:13:13 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-05-05 00:13:13 +0000 |
commit | 1d33f8d8a0d7e4a7ef47562a754b0791f7a211d4 (patch) | |
tree | 9acf17ccd4313b8a9c0db2c8b4b0411bea807ad3 /clang/test/SemaCXX/overloaded-operator.cpp | |
parent | 85c011ddc49cb2b108baaca6b36b76b9dcfd7119 (diff) | |
download | bcm5719-llvm-1d33f8d8a0d7e4a7ef47562a754b0791f7a211d4.tar.gz bcm5719-llvm-1d33f8d8a0d7e4a7ef47562a754b0791f7a211d4.zip |
With invalid overloaded operators, we can get into funny cases where
the overloading of member and non-member functions results in arity
mismatches that don't fit well into our overload-printing scheme. This
only happens for invalid code (which breaks the arity invariants for
these cases), so just suppress the diagnostic rather than inventing
anything new. Fixes <rdar://problem/9222009>.
llvm-svn: 130902
Diffstat (limited to 'clang/test/SemaCXX/overloaded-operator.cpp')
-rw-r--r-- | clang/test/SemaCXX/overloaded-operator.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/clang/test/SemaCXX/overloaded-operator.cpp b/clang/test/SemaCXX/overloaded-operator.cpp index 44d013fe796..462d0234f39 100644 --- a/clang/test/SemaCXX/overloaded-operator.cpp +++ b/clang/test/SemaCXX/overloaded-operator.cpp @@ -33,7 +33,7 @@ struct A { A make_A(); -bool operator==(A&, Z&); // expected-note 2{{candidate function}} +bool operator==(A&, Z&); // expected-note 3{{candidate function}} void h(A a, const A ac, Z z) { make_A() == z; @@ -68,7 +68,7 @@ struct E2 { }; // C++ [over.match.oper]p3 - enum restriction. -float& operator==(E1, E2); +float& operator==(E1, E2); // expected-note{{candidate function}} void enum_test(Enum1 enum1, Enum2 enum2, E1 e1, E2 e2, Enum1 next_enum1) { float &f1 = (e1 == e2); @@ -85,8 +85,8 @@ class pr5244_foo pr5244_foo(char); }; -bool operator==(const pr5244_foo& s1, const pr5244_foo& s2); -bool operator==(char c, const pr5244_foo& s); +bool operator==(const pr5244_foo& s1, const pr5244_foo& s2); // expected-note{{candidate function}} +bool operator==(char c, const pr5244_foo& s); // expected-note{{candidate function}} enum pr5244_bar { @@ -399,3 +399,12 @@ namespace rdar9136502 { y << x.i; // expected-error{{a bound member function may only be called}} } } + +namespace rdar9222009 { +class StringRef { + inline bool operator==(StringRef LHS, StringRef RHS) { // expected-error{{overloaded 'operator==' must be a binary operator (has 3 parameters)}} + return !(LHS == RHS); // expected-error{{invalid operands to binary expression ('rdar9222009::StringRef' and 'rdar9222009::StringRef')}} + } +}; + +} |