summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2011-03-22 23:15:50 +0000
committerJohn McCall <rjmccall@apple.com>2011-03-22 23:15:50 +0000
commit92d627e1b07bbb80b85832adef440c6eabce47a8 (patch)
treea22373fe01f758cb71df2ca4815c998104d81925
parent122a6304ef6a4cab93e3f12a8320427800bceceb (diff)
downloadbcm5719-llvm-92d627e1b07bbb80b85832adef440c6eabce47a8.tar.gz
bcm5719-llvm-92d627e1b07bbb80b85832adef440c6eabce47a8.zip
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. llvm-svn: 128121
-rw-r--r--clang/lib/Sema/SemaExpr.cpp19
-rw-r--r--clang/test/Sema/block-args.c5
2 files changed, 19 insertions, 5 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index a27864f673d..b8f0c729d17 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/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<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()))
diff --git a/clang/test/Sema/block-args.c b/clang/test/Sema/block-args.c
index e2e2d8e4462..5ee383eebb0 100644
--- a/clang/test/Sema/block-args.c
+++ b/clang/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]) {});
+}
OpenPOWER on IntegriCloud