From: Kaelyn Takata Date: Tue, 23 Jun 2015 18:42:21 +0000 (+0000) Subject: Ensure delayed typos have been corrected in calls to builtins before X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3148afbaba2b1d791cb5acda5af92dd2fa3b8e0f;p=clang 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@240441 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 2d2cadab9a..5813a626b0 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -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(Result.get()); + if (!TheCall) return Result; + } return CheckBuiltinFunctionCall(FDecl, BuiltinID, TheCall); + } retry: const FunctionType *FuncT; diff --git a/test/Sema/typo-correction.c b/test/Sema/typo-correction.c index d457257b3c..2f8d2b32ff 100644 --- a/test/Sema/typo-correction.c +++ b/test/Sema/typo-correction.c @@ -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'}} +}