summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/Sema/SemaExpr.cpp6
-rw-r--r--clang/test/Sema/variadic-incomplete-arg-type.c12
2 files changed, 18 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 149201192f3..6deffa2abd3 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -587,6 +587,12 @@ ExprResult Sema::DefaultVariadicArgumentPromotion(Expr *E, VariadicCallType CT,
E = Comma.get();
}
}
+ // c++ rules are enfroced elsewhere.
+ if (!getLangOptions().CPlusPlus &&
+ !E->getType()->isVoidType() &&
+ RequireCompleteType(E->getExprLoc(), E->getType(),
+ diag::err_incomplete_type))
+ return ExprError();
return Owned(E);
}
diff --git a/clang/test/Sema/variadic-incomplete-arg-type.c b/clang/test/Sema/variadic-incomplete-arg-type.c
new file mode 100644
index 00000000000..1306173a0ef
--- /dev/null
+++ b/clang/test/Sema/variadic-incomplete-arg-type.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify
+// rdar://10961370
+
+typedef struct __CFError * CFErrorRef; // expected-note {{forward declaration of 'struct __CFError'}}
+
+void junk(int, ...);
+
+int main()
+{
+ CFErrorRef error;
+ junk(1, *error); // expected-error {{incomplete type 'struct __CFError' where a complete type is required}}
+}
OpenPOWER on IntegriCloud