]> granicus.if.org Git - clang/commitdiff
Make sure we don't crash printing builtin candidates for overloads of deleted operato...
authorEli Friedman <eli.friedman@gmail.com>
Fri, 26 Aug 2011 19:46:22 +0000 (19:46 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Fri, 26 Aug 2011 19:46:22 +0000 (19:46 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138645 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaOverload.cpp
test/SemaCXX/deleted-operator.cpp [new file with mode: 0644]

index 84d16ab2b450543e6e7623994af0681f6c288d4d..e3c5f83735309a4780ce8b8e83577fc439a8323a 100644 (file)
@@ -8525,8 +8525,7 @@ Sema::CreateOverloadedUnaryOp(SourceLocation OpLoc, unsigned OpcIn,
         << 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 @@ Sema::CreateOverloadedUnaryOp(SourceLocation OpLoc, unsigned OpcIn,
       << 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 @@ Sema::CreateOverloadedBinOp(SourceLocation OpLoc,
         << 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();
   }
 
diff --git a/test/SemaCXX/deleted-operator.cpp b/test/SemaCXX/deleted-operator.cpp
new file mode 100644 (file)
index 0000000..1c8a537
--- /dev/null
@@ -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}}
+}