]> granicus.if.org Git - clang/commitdiff
Make the typo resolution in r240441 apply to all function calls.
authorKaelyn Takata <rikka@google.com>
Tue, 23 Jun 2015 19:13:17 +0000 (19:13 +0000)
committerKaelyn Takata <rikka@google.com>
Tue, 23 Jun 2015 19:13:17 +0000 (19:13 +0000)
Regular function calls (such as to cabs()) run into the same problem
with handling dependent exprs, not just builtins with custom type
checking.

Fixes PR23775.

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

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

index 5813a626b0fa34eadfbf27dccf5a0e490295c62d..2f3f4c55f10a5ef687f6146101fe99a8d4231718 100644 (file)
@@ -4937,19 +4937,20 @@ Sema::BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl,
     TheCall = new (Context) CallExpr(Context, Fn, Args, Context.BoolTy,
                                      VK_RValue, RParenLoc);
 
+  if (!getLangOpts().CPlusPlus) {
+    // C cannot always handle TypoExpr nodes in builtin calls and direct
+    // function calls as their argument checking don't necessarily 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;
+  }
+
   // Bail out early if calling a builtin with custom typechecking.
-  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;
-    }
+  if (BuiltinID && Context.BuiltinInfo.hasCustomTypechecking(BuiltinID))
     return CheckBuiltinFunctionCall(FDecl, BuiltinID, TheCall);
-  }
 
  retry:
   const FunctionType *FuncT;
index 2f8d2b32ff809b93ba9a6d10f84a82765e3f0ccd..ff43064d5b757ace96bc462a818060c2966964f3 100644 (file)
@@ -44,3 +44,8 @@ int PR23101(__m128i __x) {
 void f(long *a, long b) {
       __atomic_or_fetch(a, b, c);  // expected-error {{use of undeclared identifier 'c'}}
 }
+
+extern double cabs(_Complex double z);
+void fn1() {
+  cabs(errij);  // expected-error {{use of undeclared identifier 'errij'}}
+}