From: John McCall Date: Tue, 22 Mar 2011 23:15:50 +0000 (+0000) Subject: Fix an error with the declaration of block parameters that depend X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4f38f414b8676ea43439d6ad3315e32042d315cb;p=clang 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@128121 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index a27864f673..b8f0c729d1 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -782,11 +782,20 @@ diagnoseUncapturableValueReference(Sema &S, SourceLocation loc, // 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(var) && - S.CurContext == var->getDeclContext()->getParent()) - return CR_NoCapture; + // Certain madnesses can happen with parameter declarations, which + // we want to ignore. + if (isa(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(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(var->getDeclContext())) diff --git a/test/Sema/block-args.c b/test/Sema/block-args.c index e2e2d8e446..5ee383eebb 100644 --- a/test/Sema/block-args.c +++ b/test/Sema/block-args.c @@ -40,3 +40,8 @@ void test4() { 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]) {}); +}