aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Sema/SemaOverload.cpp4
-rw-r--r--test/SemaCXX/addr-of-overloaded-function.cpp8
2 files changed, 11 insertions, 1 deletions
diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp
index cf67f0bdd0..bd971b793a 100644
--- a/lib/Sema/SemaOverload.cpp
+++ b/lib/Sema/SemaOverload.cpp
@@ -6430,7 +6430,9 @@ Sema::ResolveAddressOfOverloadedFunction(Expr *From, QualType ToType,
<< Matches[0].second->getDeclName(),
PDiag(diag::note_ovl_candidate)
<< (unsigned) oc_function_template);
- assert(Result != MatchesCopy.end() && "no most-specialized template");
+ if (Result == MatchesCopy.end())
+ return 0;
+
MarkDeclarationReferenced(From->getLocStart(), *Result);
FoundResult = Matches[Result - MatchesCopy.begin()].first;
if (Complain) {
diff --git a/test/SemaCXX/addr-of-overloaded-function.cpp b/test/SemaCXX/addr-of-overloaded-function.cpp
index b581b8a3f6..46bdf8e6b6 100644
--- a/test/SemaCXX/addr-of-overloaded-function.cpp
+++ b/test/SemaCXX/addr-of-overloaded-function.cpp
@@ -96,3 +96,11 @@ namespace PR7971 {
static bool g(int, char);
};
}
+
+namespace PR8033 {
+ template <typename T1, typename T2> int f(T1 *, const T2 *); // expected-note{{candidate function [with T1 = const int, T2 = int]}}
+ template <typename T1, typename T2> int f(const T1 *, T2 *); // expected-note{{candidate function [with T1 = int, T2 = const int]}}
+ int (*p)(const int *, const int *) = f; // expected-error{{address of overloaded function 'f' is ambiguous}} \
+ // expected-error{{cannot initialize a variable of type}}
+
+}