[cfe-commits] r70277 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaExpr.cpp test/Sema/block-return.c
Mike Stump
mrs at apple.com
Mon Apr 27 18:10:27 PDT 2009
Author: mrs
Date: Mon Apr 27 20:10:27 2009
New Revision: 70277
URL: http://llvm.org/viewvc/llvm-project?rev=70277&view=rev
Log:
Don't allow blocks to be declared as returning an array. Radar 6441502
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/Sema/block-return.c
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=70277&r1=70276&r2=70277&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Apr 27 20:10:27 2009
@@ -1551,6 +1551,8 @@
"goto not allowed in block literal">;
def err_return_in_block_expression : Error<
"return not allowed in block expression literal">;
+def err_block_returns_array : Error<
+ "block declared as returning an array">;
def err_ret_local_block : Error<
"returning block that lives on the local stack">;
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=70277&r1=70276&r2=70277&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Mon Apr 27 20:10:27 2009
@@ -4726,6 +4726,12 @@
|| ParamInfo.getTypeObject(0).Kind != DeclaratorChunk::Function) {
QualType T = GetTypeForDeclarator(ParamInfo, CurScope);
+ if (T->isArrayType()) {
+ Diag(ParamInfo.getSourceRange().getBegin(),
+ diag::err_block_returns_array);
+ return;
+ }
+
// The parameter list is optional, if there was none, assume ().
if (!T->isFunctionType())
T = Context.getFunctionType(T, NULL, 0, 0, 0);
Modified: cfe/trunk/test/Sema/block-return.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/block-return.c?rev=70277&r1=70276&r2=70277&view=diff
==============================================================================
--- cfe/trunk/test/Sema/block-return.c (original)
+++ cfe/trunk/test/Sema/block-return.c Mon Apr 27 20:10:27 2009
@@ -92,3 +92,6 @@
return ^{ ^{ i=0; }(); }; // expected-error {{returning block that lives on the local stack}}
return ^{ i=0; }; // expected-error {{returning block that lives on the local stack}}
}
+
+int (*funcptr3[5])(long);
+int sz8 = sizeof(^int (*[5])(long) {return funcptr3;}); // expected-error {{block declared as returning an array}}
More information about the cfe-commits
mailing list