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();
}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@286748 91177308-0d34-0410-b5e6-96231b3b80d8
(cherry picked from commit e3fbde7486a0e43ef164ba7f93134d4b103867bf)
4 files changed