r302435 - [Sema] Fix typos handling in an overloadable call.

Anastasia Stulova via cfe-commits cfe-commits at lists.llvm.org
Mon May 8 09:05:55 PDT 2017


Author: stulova
Date: Mon May  8 11:05:54 2017
New Revision: 302435

URL: http://llvm.org/viewvc/llvm-project?rev=302435&view=rev
Log:
[Sema] Fix typos handling in an overloadable call.

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!


Modified:
    cfe/trunk/lib/Sema/SemaExpr.cpp
    cfe/trunk/test/Sema/typo-correction.c

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=302435&r1=302434&r2=302435&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Mon May  8 11:05:54 2017
@@ -5277,6 +5277,9 @@ ExprResult Sema::ActOnCallExpr(Scope *Sc
 
     // 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(

Modified: cfe/trunk/test/Sema/typo-correction.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/typo-correction.c?rev=302435&r1=302434&r2=302435&view=diff
==============================================================================
--- cfe/trunk/test/Sema/typo-correction.c (original)
+++ cfe/trunk/test/Sema/typo-correction.c Mon May  8 11:05:54 2017
@@ -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}}
+}




More information about the cfe-commits mailing list