[cfe-commits] r128121 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/Sema/block-args.c
John McCall
rjmccall at apple.com
Tue Mar 22 16:15:50 PDT 2011
Author: rjmccall
Date: Tue Mar 22 18:15:50 2011
New Revision: 128121
URL: http://llvm.org/viewvc/llvm-project?rev=128121&view=rev
Log:
Fix an error with the declaration of block parameters that depend
on previous block parameters that crept in as part of my captures
work a month or so ago.
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/Sema/block-args.c
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=128121&r1=128120&r2=128121&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Mar 22 18:15:50 2011
@@ -782,11 +782,20 @@
// diagnose this.
if (!S.CurContext->isFunctionOrMethod()) return CR_NoCapture;
- // This particular madness can happen in ill-formed default
- // arguments; claim it's okay and let downstream code handle it.
- if (isa<ParmVarDecl>(var) &&
- S.CurContext == var->getDeclContext()->getParent())
- return CR_NoCapture;
+ // Certain madnesses can happen with parameter declarations, which
+ // we want to ignore.
+ if (isa<ParmVarDecl>(var)) {
+ // - If the parameter still belongs to the translation unit, then
+ // we're actually just using one parameter in the declaration of
+ // the next. This is useful in e.g. VLAs.
+ if (isa<TranslationUnitDecl>(var->getDeclContext()))
+ return CR_NoCapture;
+
+ // - This particular madness can happen in ill-formed default
+ // arguments; claim it's okay and let downstream code handle it.
+ if (S.CurContext == var->getDeclContext()->getParent())
+ return CR_NoCapture;
+ }
DeclarationName functionName;
if (FunctionDecl *fn = dyn_cast<FunctionDecl>(var->getDeclContext()))
Modified: cfe/trunk/test/Sema/block-args.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/block-args.c?rev=128121&r1=128120&r2=128121&view=diff
==============================================================================
--- cfe/trunk/test/Sema/block-args.c (original)
+++ cfe/trunk/test/Sema/block-args.c Tue Mar 22 18:15:50 2011
@@ -40,3 +40,8 @@
int (^f)() = ^((x)) { }; // expected-error {{expected ')'}} expected-warning {{type specifier missing}} expected-note {{to match this}}
}
+// rdar://problem/9170609
+void test5_helper(void (^)(int, int[*]));
+void test5(void) {
+ test5_helper(^(int n, int array[n]) {});
+}
More information about the cfe-commits
mailing list