diff options
| -rw-r--r-- | clang/lib/Sema/SemaExprCXX.cpp | 9 | ||||
| -rw-r--r-- | clang/test/SemaCXX/typo-correction-delayed.cpp | 20 |
2 files changed, 27 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index e8be716ea09..554e8c9b8fd 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -6105,8 +6105,13 @@ public: auto Result = BaseTransform::RebuildCallExpr(Callee, LParenLoc, Args, RParenLoc, ExecConfig); if (auto *OE = dyn_cast<OverloadExpr>(Callee)) { - if (!Result.isInvalid() && Result.get()) - OverloadResolution[OE] = cast<CallExpr>(Result.get())->getCallee(); + if (!Result.isInvalid() && Result.get()) { + Expr *ResultCall = Result.get(); + if (auto *BE = dyn_cast<CXXBindTemporaryExpr>(ResultCall)) + ResultCall = BE->getSubExpr(); + if (auto *CE = dyn_cast<CallExpr>(ResultCall)) + OverloadResolution[OE] = CE->getCallee(); + } } return Result; } diff --git a/clang/test/SemaCXX/typo-correction-delayed.cpp b/clang/test/SemaCXX/typo-correction-delayed.cpp index d303b58554d..d42888f1e6a 100644 --- a/clang/test/SemaCXX/typo-correction-delayed.cpp +++ b/clang/test/SemaCXX/typo-correction-delayed.cpp @@ -119,3 +119,23 @@ class SomeClass { public: explicit SomeClass() : Kind(kSum) {} // expected-error {{use of undeclared identifier 'kSum'; did you mean 'kNum'?}} }; + +extern "C" int printf(const char *, ...); + +// There used to be an issue with typo resolution inside overloads. +struct AssertionResult { + ~AssertionResult(); + operator bool(); + int val; +}; +AssertionResult Compare(const char *a, const char *b); +AssertionResult Compare(int a, int b); +int main() { + // expected-note@+1 {{'result' declared here}} + const char *result; + // expected-error@+1 {{use of undeclared identifier 'resulta'; did you mean 'result'?}} + if (AssertionResult ar = (Compare("value1", resulta))) + ; + else + printf("ar: %d\n", ar.val); +} |

