Author: rikka
Date: Tue Jun 23 13:42:21 2015
New Revision: 240441

URL: http://llvm.org/viewvc/llvm-project?rev=240441&view=rev
Log:
Ensure delayed typos have been corrected in calls to builtins before
checking those calls when not in C++ mode, since those code paths can't
handle dependent exprs.

Fixes PR23740.

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=240441&r1=240440&r2=240441&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Jun 23 13:42:21 2015
@@ -4938,8 +4938,18 @@ Sema::BuildResolvedCallExpr(Expr *Fn, Na
                                      VK_RValue, RParenLoc);
 
   // Bail out early if calling a builtin with custom typechecking.
-  if (BuiltinID && Context.BuiltinInfo.hasCustomTypechecking(BuiltinID))
+  if (BuiltinID && Context.BuiltinInfo.hasCustomTypechecking(BuiltinID)) {
+    if (!getLangOpts().CPlusPlus) {
+      // C cannot handle TypoExpr nodes in the builtin's call expr because it
+      // doesn't handle dependent types properly, so make sure any TypoExprs 
have
+      // been dealt with.
+      ExprResult Result = CorrectDelayedTyposInExpr(TheCall);
+      if (!Result.isUsable()) return ExprError();
+      TheCall = dyn_cast<CallExpr>(Result.get());
+      if (!TheCall) return Result;
+    }
     return CheckBuiltinFunctionCall(FDecl, BuiltinID, TheCall);
+  }
 
  retry:
   const FunctionType *FuncT;

Modified: cfe/trunk/test/Sema/typo-correction.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/typo-correction.c?rev=240441&r1=240440&r2=240441&view=diff
==============================================================================
--- cfe/trunk/test/Sema/typo-correction.c (original)
+++ cfe/trunk/test/Sema/typo-correction.c Tue Jun 23 13:42:21 2015
@@ -40,3 +40,7 @@ int PR23101(__m128i __x) {
   return foo((__v2di)__x);  // expected-warning {{implicit declaration of 
function 'foo'}} \
                             // expected-error {{use of undeclared identifier 
'__v2di'}}
 }
+
+void f(long *a, long b) {
+      __atomic_or_fetch(a, b, c);  // expected-error {{use of undeclared 
identifier 'c'}}
+}


_______________________________________________
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to