]> granicus.if.org Git - clang/commitdiff
Check for non-POD vararg argument type after default argument promotion, not
authorRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 27 Jun 2012 20:23:58 +0000 (20:23 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 27 Jun 2012 20:23:58 +0000 (20:23 +0000)
before, so we don't incorrectly think arguments of function type are non-POD.

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

lib/Sema/SemaExpr.cpp
test/CodeGen/varargs.c

index 2a7a8b9f19554676870da39d8e762adaac3d1d8d..aec941c4c1cc92493d6a5506ad60f5229c683f3f 100644 (file)
@@ -679,7 +679,7 @@ ExprResult Sema::DefaultVariadicArgumentPromotion(Expr *E, VariadicCallType CT,
 
   // Diagnostics regarding non-POD argument types are
   // emitted along with format string checking in Sema::CheckFunctionCall().
-  if (isValidVarArgType(Ty) == VAK_Invalid) {
+  if (isValidVarArgType(E->getType()) == VAK_Invalid) {
     // Turn this into a trap.
     CXXScopeSpec SS;
     SourceLocation TemplateKWLoc;
index b3dba240b559e22666124e8b145ccc8c51a0c94b..b6973d8337d85952ce05760a09e611066437a2cb 100644 (file)
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -emit-llvm -o - %s
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
 
 
 // PR6433 - Don't crash on va_arg(typedef).
@@ -9,3 +9,9 @@ void focus_changed_cb () {
     mfloat = __builtin_va_arg((pa), gdouble);
 }
 
+void vararg(int, ...);
+void function_as_vararg() {
+  // CHECK: define {{.*}}function_as_vararg
+  // CHECK-NOT: llvm.trap
+  vararg(0, focus_changed_cb);
+}