[cfe-commits] r138645 - in /cfe/trunk: lib/Sema/SemaOverload.cpp test/SemaCXX/deleted-operator.cpp

Eli Friedman eli.friedman at gmail.com
Fri Aug 26 12:46:22 PDT 2011


Author: efriedma
Date: Fri Aug 26 14:46:22 2011
New Revision: 138645

URL: http://llvm.org/viewvc/llvm-project?rev=138645&view=rev
Log:
Make sure we don't crash printing builtin candidates for overloads of deleted operators.  Fixes PR10757.


Added:
    cfe/trunk/test/SemaCXX/deleted-operator.cpp
Modified:
    cfe/trunk/lib/Sema/SemaOverload.cpp

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=138645&r1=138644&r2=138645&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Fri Aug 26 14:46:22 2011
@@ -8525,8 +8525,7 @@
         << UnaryOperator::getOpcodeStr(Opc)
         << Input->getType()
         << Input->getSourceRange();
-    CandidateSet.NoteCandidates(*this, OCD_ViableCandidates,
-                                Args, NumArgs,
+    CandidateSet.NoteCandidates(*this, OCD_ViableCandidates, Args, NumArgs,
                                 UnaryOperator::getOpcodeStr(Opc), OpLoc);
     return ExprError();
 
@@ -8536,7 +8535,8 @@
       << UnaryOperator::getOpcodeStr(Opc)
       << getDeletedOrUnavailableSuffix(Best->Function)
       << Input->getSourceRange();
-    CandidateSet.NoteCandidates(*this, OCD_AllCandidates, Args, NumArgs);
+    CandidateSet.NoteCandidates(*this, OCD_AllCandidates, Args, NumArgs,
+                                UnaryOperator::getOpcodeStr(Opc), OpLoc);
     return ExprError();
   }
 
@@ -8831,7 +8831,8 @@
         << BinaryOperator::getOpcodeStr(Opc)
         << getDeletedOrUnavailableSuffix(Best->Function)
         << Args[0]->getSourceRange() << Args[1]->getSourceRange();
-      CandidateSet.NoteCandidates(*this, OCD_AllCandidates, Args, 2);
+      CandidateSet.NoteCandidates(*this, OCD_AllCandidates, Args, 2,
+                                  BinaryOperator::getOpcodeStr(Opc), OpLoc);
       return ExprError();
   }
 

Added: cfe/trunk/test/SemaCXX/deleted-operator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/deleted-operator.cpp?rev=138645&view=auto
==============================================================================
--- cfe/trunk/test/SemaCXX/deleted-operator.cpp (added)
+++ cfe/trunk/test/SemaCXX/deleted-operator.cpp Fri Aug 26 14:46:22 2011
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s
+
+struct PR10757 {
+  bool operator~() = delete; // expected-note {{explicitly deleted}}
+  bool operator==(const PR10757&) = delete; // expected-note {{explicitly deleted}}
+  operator float();
+};
+int PR10757f() {
+  PR10757 a1;
+  // FIXME: We get a ridiculous number of "built-in candidate" notes here...
+  if(~a1) {} // expected-error {{overload resolution selected deleted operator}} expected-note 6 {{built-in candidate}}
+  if(a1==a1) {} // expected-error {{overload resolution selected deleted operator}} expected-note 81 {{built-in candidate}}
+}





More information about the cfe-commits mailing list