From: Hans Wennborg Date: Fri, 12 Jun 2015 21:23:23 +0000 (+0000) Subject: [ms] Don't try to delay lookup for failures in SFINAE context (PR23823) X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a0c6e28c65a3f2549059875b2c07a9cedd765139;p=clang [ms] Don't try to delay lookup for failures in SFINAE context (PR23823) The underlying problem in PR23823 already existed before my recent change in r239558, but that change made it worse (failing not only for undeclared symbols, but also failed overload resolution). This makes Clang not try to delay the lookup in SFINAE context. I assume no current code is relying on SFINAE working with lookups that need to be delayed, because that never seems to have worked. Differential Revision: http://reviews.llvm.org/D10417 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@239639 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp index 117ca135a2..f8610e009b 100644 --- a/lib/Sema/SemaOverload.cpp +++ b/lib/Sema/SemaOverload.cpp @@ -10750,7 +10750,8 @@ bool Sema::buildOverloadedCallSet(Scope *S, Expr *Fn, // functions, including those from argument-dependent lookup. AddOverloadedCallCandidates(ULE, Args, *CandidateSet); - if (getLangOpts().MSVCCompat && CurContext->isDependentContext() && + if (getLangOpts().MSVCCompat && + CurContext->isDependentContext() && !isSFINAEContext() && (isa(CurContext) || isa(CurContext))) { OverloadCandidateSet::iterator Best; diff --git a/test/SemaTemplate/ms-lookup-template-base-classes.cpp b/test/SemaTemplate/ms-lookup-template-base-classes.cpp index 90e9f0a48a..9fa59e626e 100644 --- a/test/SemaTemplate/ms-lookup-template-base-classes.cpp +++ b/test/SemaTemplate/ms-lookup-template-base-classes.cpp @@ -563,3 +563,13 @@ void test() { x.member(); // expected-note{{requested here}} }; } + +namespace PR23823 { +// Don't delay lookup in SFINAE context. +template decltype(g(T())) check(); // expected-note{{candidate template ignored: substitution failure [with T = int]: use of undeclared identifier 'g'}} +decltype(check()) x; // expected-error{{no matching function for call to 'check'}} + +void h(); +template decltype(h(T())) check2(); // expected-note{{candidate template ignored: substitution failure [with T = int]: no matching function for call to 'h'}} +decltype(check2()) y; // expected-error{{no matching function for call to 'check2'}} +}