]> granicus.if.org Git - clang/commitdiff
Ensure that any TypoExprs in the arguments to bultins with custom type
authorKaelyn Takata <rikka@google.com>
Tue, 25 Nov 2014 23:04:09 +0000 (23:04 +0000)
committerKaelyn Takata <rikka@google.com>
Tue, 25 Nov 2014 23:04:09 +0000 (23:04 +0000)
checking are handled before the custom type checking is performed.

Fixes PR21669.

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

lib/Sema/SemaExpr.cpp
test/SemaCXX/typo-correction-delayed.cpp

index 223e93e7c3d15d70efaa313bf1ef9b14371f7f74..ae299c3c98e89ee9531ef6e63e3cc5123170fc42 100644 (file)
@@ -4752,8 +4752,12 @@ 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))
-    return CheckBuiltinFunctionCall(FDecl, BuiltinID, TheCall);
+  if (BuiltinID && Context.BuiltinInfo.hasCustomTypechecking(BuiltinID)) {
+    ExprResult Res = CorrectDelayedTyposInExpr(TheCall);
+    if (!Res.isUsable() || !isa<CallExpr>(Res.get()))
+      return Res;
+    return CheckBuiltinFunctionCall(FDecl, BuiltinID, cast<CallExpr>(Res.get()));
+  }
 
  retry:
   const FunctionType *FuncT;
index 124f0ec2a1ca202f5771c057ab337cb2acd1f88f..bff1d7633fc6adf3eb7a3febaa20db4b2f08661e 100644 (file)
@@ -93,3 +93,12 @@ void f(NestedNode *node) {
   NestedNode *next = node->Next();  // expected-error-re {{no member named 'Next' in 'initializerCorrections::NestedNode'{{$}}}}
 }
 }
+
+namespace PR21669 {
+void f(int *i) {
+  // Check that arguments to a builtin with custom type checking are corrected
+  // properly, since calls to such builtins bypass much of the normal code path
+  // for building and checking the call.
+  __atomic_load(i, i, something_something);  // expected-error-re {{use of undeclared identifier 'something_something'{{$}}}}
+}
+}