diff options
author | John McCall <rjmccall@apple.com> | 2011-03-22 23:15:50 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2011-03-22 23:15:50 +0000 |
commit | 4f38f414b8676ea43439d6ad3315e32042d315cb (patch) | |
tree | a68ffccc60cb377092b48278a880b409aaf5b3fe /lib/Sema/SemaExpr.cpp | |
parent | ac4df2454d5462c3bf5f369d65c3ad651100fa40 (diff) |
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
Diffstat (limited to 'lib/Sema/SemaExpr.cpp')
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
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<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())) |