Skip to content

Commit abca85b

Browse files
committed
[clang][Interp] Remove faulty assertion
The assertion doesn't work if there are multiple declarations for a variable involved.
1 parent 024c3d0 commit abca85b

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

clang/lib/AST/Interp/Program.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@ std::optional<unsigned> Program::getOrCreateDummy(const ValueDecl *VD) {
169169

170170
std::optional<unsigned> Program::createGlobal(const ValueDecl *VD,
171171
const Expr *Init) {
172-
assert(!getGlobal(VD));
173172
bool IsStatic, IsExtern;
174173
if (const auto *Var = dyn_cast<VarDecl>(VD)) {
175174
IsStatic = Context::shouldBeGloballyIndexed(VD);

clang/test/AST/Interp/literals.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,4 +1209,16 @@ constexpr int externvar1() { // both-error {{never produces a constant expressio
12091209
namespace Extern {
12101210
constexpr extern char Oops = 1;
12111211
static_assert(Oops == 1, "");
1212+
1213+
#if __cplusplus >= 201402L
1214+
struct NonLiteral {
1215+
NonLiteral() {}
1216+
};
1217+
NonLiteral nl;
1218+
constexpr NonLiteral &ExternNonLiteralVarDecl() {
1219+
extern NonLiteral nl;
1220+
return nl;
1221+
}
1222+
static_assert(&ExternNonLiteralVarDecl() == &nl, "");
1223+
#endif
12121224
}

0 commit comments

Comments
 (0)