[cfe-commits] r151862 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/Sema/variadic-incomplete-arg-type.c
Fariborz Jahanian
fjahanian at apple.com
Thu Mar 1 15:42:01 PST 2012
Author: fjahanian
Date: Thu Mar 1 17:42:00 2012
New Revision: 151862
URL: http://llvm.org/viewvc/llvm-project?rev=151862&view=rev
Log:
c/objc: problem originally reported as an objective-c bug.
But it is in the underlying c part of clang. clang crashes
in IRGen when passing an incomplete type argument to
variadic function (instead of diagnosing the bug).
// rdar://10961370
Added:
cfe/trunk/test/Sema/variadic-incomplete-arg-type.c
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=151862&r1=151861&r2=151862&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu Mar 1 17:42:00 2012
@@ -587,6 +587,12 @@
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);
}
Added: cfe/trunk/test/Sema/variadic-incomplete-arg-type.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/variadic-incomplete-arg-type.c?rev=151862&view=auto
==============================================================================
--- cfe/trunk/test/Sema/variadic-incomplete-arg-type.c (added)
+++ cfe/trunk/test/Sema/variadic-incomplete-arg-type.c Thu Mar 1 17:42:00 2012
@@ -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}}
+}
More information about the cfe-commits
mailing list