Fix PR28366: Handle variables from enclosing local scopes more gracefully during...
authorFaisal Vali <faisalv@yahoo.com>
Sun, 13 Nov 2016 06:09:16 +0000 (06:09 +0000)
committerFaisal Vali <faisalv@yahoo.com>
Sun, 13 Nov 2016 06:09:16 +0000 (06:09 +0000)
commit0528a31ddf430bdeb1711ba930b6d530f78af3ad
treed377b3d2fe1fa4e50f34113dccdae8c7bcca4f2e
parente706c1d9d91ecec741ef1dacdef629f3f8cb5f35
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
clang/lib/AST/ExprConstant.cpp
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/test/SemaCXX/constant-expression-cxx11.cpp
clang/test/SemaCXX/cxx1z-constexpr-lambdas.cpp