mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-11-27 23:51:56 +00:00
[clang][Interp] Only lazily visit constant globals
Differential Revision: https://reviews.llvm.org/D158516
This commit is contained in:
parent
5c4d35d8cf
commit
4d7f4a7c82
@ -2536,7 +2536,8 @@ bool ByteCodeExprGen<Emitter>::VisitDeclRefExpr(const DeclRefExpr *E) {
|
||||
// This happens in C.
|
||||
if (!Ctx.getLangOpts().CPlusPlus) {
|
||||
if (const auto *VD = dyn_cast<VarDecl>(D);
|
||||
VD && VD->hasGlobalStorage() && VD->getAnyInitializer()) {
|
||||
VD && VD->hasGlobalStorage() && VD->getAnyInitializer() &&
|
||||
VD->getType().isConstQualified()) {
|
||||
if (!this->visitVarDecl(VD))
|
||||
return false;
|
||||
// Retry.
|
||||
|
@ -14,11 +14,15 @@ _Static_assert(!!1.0, ""); // pedantic-ref-warning {{not an integer constant exp
|
||||
// pedantic-expected-warning {{not an integer constant expression}}
|
||||
_Static_assert(!!1, "");
|
||||
|
||||
/// FIXME: Should also be rejected in the new interpreter
|
||||
int a = (1 == 1 ? 5 : 3);
|
||||
int a = (1 == 1 ? 5 : 3); // expected-note {{declared here}} \
|
||||
// pedantic-expected-note {{declared here}}
|
||||
_Static_assert(a == 5, ""); // ref-error {{not an integral constant expression}} \
|
||||
// pedantic-ref-error {{not an integral constant expression}} \
|
||||
// pedantic-expected-warning {{not an integer constant expression}}
|
||||
// expected-error {{not an integral constant expression}} \
|
||||
// expected-note {{read of non-const variable}} \
|
||||
// pedantic-expected-error {{not an integral constant expression}} \
|
||||
// pedantic-expected-note {{read of non-const variable}}
|
||||
|
||||
|
||||
const int b = 3;
|
||||
_Static_assert(b == 3, ""); // pedantic-ref-warning {{not an integer constant expression}} \
|
||||
|
Loading…
Reference in New Issue
Block a user