]> granicus.if.org Git - clang/commitdiff
Ensure delayed typos have been corrected in calls to builtins before
authorKaelyn Takata <rikka@google.com>
Tue, 23 Jun 2015 18:42:21 +0000 (18:42 +0000)
committerKaelyn Takata <rikka@google.com>
Tue, 23 Jun 2015 18:42:21 +0000 (18:42 +0000)
checking those calls when not in C++ mode, since those code paths can't
handle dependent exprs.

Fixes PR23740.

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

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

index 2d2cadab9a37e14ba05085535e8fa1abb9aae8a1..5813a626b0fa34eadfbf27dccf5a0e490295c62d 100644 (file)
@@ -4938,8 +4938,18 @@ Sema::BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl,
                                      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;
index d457257b3c3a517ed7a564582a2e21431ae91415..2f8d2b32ff809b93ba9a6d10f84a82765e3f0ccd 100644 (file)
@@ -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'}}
+}