From ccd471341d2edbb18ac9c46a7c65d280d9c6223e Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Tue, 8 Jun 2010 21:03:17 +0000 Subject: [PATCH] A built-in overload candidate is consider a non-template function when determining whether one overload candidate is better than another. Fixes PR7319. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105642 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaOverload.cpp | 2 +- test/SemaCXX/overloaded-builtin-operators.cpp | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp index 6a020d57d3..d746ec3f6d 100644 --- a/lib/Sema/SemaOverload.cpp +++ b/lib/Sema/SemaOverload.cpp @@ -4955,7 +4955,7 @@ Sema::isBetterOverloadCandidate(const OverloadCandidate& Cand1, // - F1 is a non-template function and F2 is a function template // specialization, or, if not that, - if (Cand1.Function && !Cand1.Function->getPrimaryTemplate() && + if ((!Cand1.Function || !Cand1.Function->getPrimaryTemplate()) && Cand2.Function && Cand2.Function->getPrimaryTemplate()) return true; diff --git a/test/SemaCXX/overloaded-builtin-operators.cpp b/test/SemaCXX/overloaded-builtin-operators.cpp index 61c2e2110a..1ba9452466 100644 --- a/test/SemaCXX/overloaded-builtin-operators.cpp +++ b/test/SemaCXX/overloaded-builtin-operators.cpp @@ -188,3 +188,14 @@ int test_pr5432() { void f() { (void)__extension__(A()); } + +namespace PR7319 { + typedef enum { Enum1, Enum2, Enum3 } MyEnum; + + template bool operator>(const X &inX1, const X &inX2); + + void f() { + MyEnum e1, e2; + if (e1 > e2) {} + } +} -- 2.50.1