]> granicus.if.org Git - clang/commitdiff
[Sema] Fix typos handling in an overloadable call.
authorAnastasia Stulova <anastasia.stulova@arm.com>
Mon, 8 May 2017 16:05:54 +0000 (16:05 +0000)
committerAnastasia Stulova <anastasia.stulova@arm.com>
Mon, 8 May 2017 16:05:54 +0000 (16:05 +0000)
In C typos in arguments in a call of an overloadable function lead
to a failure of construction of CallExpr and following recovery does
not handle created delayed typos. This causes an assertion fail in
Sema::~Sema since Sema::DelayedTypos remains not empty.

The patch fixes that behavior by handling a call with arguments
having dependant types in the way that C++ does.

Differential Revision: https://reviews.llvm.org/D31764

Patch by Dmitry Borisenkov!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@302435 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExpr.cpp
test/Sema/typo-correction.c

index 849e978e2d86e93fcf4ee59be6e9a30679ec3424..c32c91e7064ec1ed3f3431349aea835153911ae6 100644 (file)
@@ -5277,6 +5277,9 @@ ExprResult Sema::ActOnCallExpr(Scope *Scope, Expr *Fn, SourceLocation LParenLoc,
 
     // We aren't supposed to apply this logic if there's an '&' involved.
     if (!find.HasFormOfMemberPointer) {
+      if (Expr::hasAnyTypeDependentArguments(ArgExprs))
+        return new (Context) CallExpr(
+            Context, Fn, ArgExprs, Context.DependentTy, VK_RValue, RParenLoc);
       OverloadExpr *ovl = find.Expression;
       if (UnresolvedLookupExpr *ULE = dyn_cast<UnresolvedLookupExpr>(ovl))
         return BuildOverloadedCallExpr(
index 59f022dfe528cf9e1796a0b3d547a0564e59aa7c..78007015dcaed49c62e51633e7fd1af34ffb5021 100644 (file)
@@ -80,3 +80,10 @@ int h() {
   g(x, 5 ? z : 0); // expected-error 2 {{use of undeclared identifier}}
   (x, 5 ? z : 0);  // expected-error 2 {{use of undeclared identifier}}
 }
+
+__attribute__((overloadable)) void func_overloadable(int);
+__attribute__((overloadable)) void func_overloadable(float);
+
+void overloadable_callexpr(int arg) {
+       func_overloadable(ar); //expected-error{{use of undeclared identifier}}
+}