]> granicus.if.org Git - clang/commitdiff
Don't try to diagnose anything when we're passing incomplete types
authorDouglas Gregor <dgregor@apple.com>
Fri, 14 Oct 2011 20:34:19 +0000 (20:34 +0000)
committerDouglas Gregor <dgregor@apple.com>
Fri, 14 Oct 2011 20:34:19 +0000 (20:34 +0000)
through varargs. This only happens when we're in an unevaluated
context, where we don't want to trigger an error anyway. Fixes PR11131
/ <rdar://problem/10288375>.

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

lib/Sema/SemaExpr.cpp
test/CXX/expr/expr.post/expr.call/p7-0x.cpp
test/SemaCXX/vararg-non-pod.cpp

index 97060772b0a1506ba8e9463f94f17375dda78486..41fcf7299dbeefb3aa6fb6cd906ad0b0d3c918a3 100644 (file)
@@ -523,7 +523,10 @@ ExprResult Sema::DefaultVariadicArgumentPromotion(Expr *E, VariadicCallType CT,
                           << E->getType() << CT))
     return ExprError();
 
-  if (!E->getType().isPODType(Context)) {
+  // Complain about passing non-POD types through varargs. However, don't
+  // perform this check for incomplete types, which we can get here when we're
+  // in an unevaluated context.
+  if (!E->getType()->isIncompleteType() && !E->getType().isPODType(Context)) {
     // C++0x [expr.call]p7:
     //   Passing a potentially-evaluated argument of class type (Clause 9) 
     //   having a non-trivial copy constructor, a non-trivial move constructor,
index e6ffebc8d84feb3d407f765bec4a0ba2d26bccfe..d51ba09835d27e0af3301d09bdfb9f6022d5487a 100644 (file)
@@ -15,3 +15,16 @@ void f(X1 x1, X2 x2) {
   vararg(x1); // okay
   vararg(x2); // expected-error{{cannot pass object of non-trivial type 'X2' through variadic function; call will abort at runtime}}
 }
+
+
+namespace PR11131 {
+  struct S;
+
+  S &getS();
+
+  void f(...);
+
+  void g() {
+    (void)sizeof(f(getS()));
+  }
+}
index 3ca07b0215c39c7beabe08768c6dcba8a2e0d824..42c27fb30e1bc20134428bfcb3fa7a9e4a12c656 100644 (file)
@@ -118,4 +118,3 @@ void t8(int n, ...) {
   (void)__builtin_va_arg(list, Abstract); // expected-error{{second argument to 'va_arg' is of abstract type 'Abstract'}}
   __builtin_va_end(list);
 }
-