diff options
author | Faisal Vali <faisalv@yahoo.com> | 2016-11-13 06:09:16 +0000 |
---|---|---|
committer | Faisal Vali <faisalv@yahoo.com> | 2016-11-13 06:09:16 +0000 |
commit | 0528a31ddf430bdeb1711ba930b6d530f78af3ad (patch) | |
tree | d377b3d2fe1fa4e50f34113dccdae8c7bcca4f2e /clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | |
parent | e706c1d9d91ecec741ef1dacdef629f3f8cb5f35 (diff) | |
download | bcm5719-llvm-0528a31ddf430bdeb1711ba930b6d530f78af3ad.tar.gz bcm5719-llvm-0528a31ddf430bdeb1711ba930b6d530f78af3ad.zip |
Fix PR28366: Handle variables from enclosing local scopes more gracefully during constant expression evaluation.
Only look for a variable's value in the constant expression evaluation activation frame, if the variable was indeed declared in that frame, otherwise it might be a constant expression and be usable within a nested local scope or emit an error.
void f(char c) {
struct X {
static constexpr char f() {
return c; // error gracefully here as opposed to crashing.
}
};
int I = X::f();
}
llvm-svn: 286748
Diffstat (limited to 'clang/lib/Sema/SemaTemplateInstantiateDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index 911bc512c87..e80c75d298d 100644 --- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -188,7 +188,7 @@ static void instantiateDependentEnableIfAttr( SmallVector<PartialDiagnosticAt, 8> Diags; if (A->getCond()->isValueDependent() && !Cond->isValueDependent() && - !Expr::isPotentialConstantExprUnevaluated(Cond, cast<FunctionDecl>(Tmpl), + !Expr::isPotentialConstantExprUnevaluated(Cond, cast<FunctionDecl>(New), Diags)) { S.Diag(A->getLocation(), diag::err_enable_if_never_constant_expr); for (int I = 0, N = Diags.size(); I != N; ++I) |