[cfe-commits] r141986 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/CXX/expr/expr.post/expr.call/p7-0x.cpp test/SemaCXX/vararg-non-pod.cpp

Douglas Gregor dgregor at apple.com
Fri Oct 14 13:34:19 PDT 2011


Author: dgregor
Date: Fri Oct 14 15:34:19 2011
New Revision: 141986

URL: http://llvm.org/viewvc/llvm-project?rev=141986&view=rev
Log:
Don't try to diagnose anything when we're passing incomplete types
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>.

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

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=141986&r1=141985&r2=141986&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri Oct 14 15:34:19 2011
@@ -523,7 +523,10 @@
                           << 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,

Modified: cfe/trunk/test/CXX/expr/expr.post/expr.call/p7-0x.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/expr/expr.post/expr.call/p7-0x.cpp?rev=141986&r1=141985&r2=141986&view=diff
==============================================================================
--- cfe/trunk/test/CXX/expr/expr.post/expr.call/p7-0x.cpp (original)
+++ cfe/trunk/test/CXX/expr/expr.post/expr.call/p7-0x.cpp Fri Oct 14 15:34:19 2011
@@ -15,3 +15,16 @@
   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()));
+  }
+}

Modified: cfe/trunk/test/SemaCXX/vararg-non-pod.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/vararg-non-pod.cpp?rev=141986&r1=141985&r2=141986&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/vararg-non-pod.cpp (original)
+++ cfe/trunk/test/SemaCXX/vararg-non-pod.cpp Fri Oct 14 15:34:19 2011
@@ -118,4 +118,3 @@
   (void)__builtin_va_arg(list, Abstract); // expected-error{{second argument to 'va_arg' is of abstract type 'Abstract'}}
   __builtin_va_end(list);
 }
-





More information about the cfe-commits mailing list