[clang] abca85b - [clang][Interp] Remove faulty assertion
Timm Bäder via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 22 06:28:42 PDT 2024
Author: Timm Bäder
Date: 2024-04-22T15:28:00+02:00
New Revision: abca85b3f7d5d3a1ae8dfea37d41e913c67b9bab
URL: https://github.com/llvm/llvm-project/commit/abca85b3f7d5d3a1ae8dfea37d41e913c67b9bab
DIFF: https://github.com/llvm/llvm-project/commit/abca85b3f7d5d3a1ae8dfea37d41e913c67b9bab.diff
LOG: [clang][Interp] Remove faulty assertion
The assertion doesn't work if there are multiple declarations for
a variable involved.
Added:
Modified:
clang/lib/AST/Interp/Program.cpp
clang/test/AST/Interp/literals.cpp
Removed:
################################################################################
diff --git a/clang/lib/AST/Interp/Program.cpp b/clang/lib/AST/Interp/Program.cpp
index 7bf842f1a9404b..3773e0662f784c 100644
--- a/clang/lib/AST/Interp/Program.cpp
+++ b/clang/lib/AST/Interp/Program.cpp
@@ -169,7 +169,6 @@ std::optional<unsigned> Program::getOrCreateDummy(const ValueDecl *VD) {
std::optional<unsigned> Program::createGlobal(const ValueDecl *VD,
const Expr *Init) {
- assert(!getGlobal(VD));
bool IsStatic, IsExtern;
if (const auto *Var = dyn_cast<VarDecl>(VD)) {
IsStatic = Context::shouldBeGloballyIndexed(VD);
diff --git a/clang/test/AST/Interp/literals.cpp b/clang/test/AST/Interp/literals.cpp
index 277438d2e63114..2688b53adde248 100644
--- a/clang/test/AST/Interp/literals.cpp
+++ b/clang/test/AST/Interp/literals.cpp
@@ -1209,4 +1209,16 @@ constexpr int externvar1() { // both-error {{never produces a constant expressio
namespace Extern {
constexpr extern char Oops = 1;
static_assert(Oops == 1, "");
+
+#if __cplusplus >= 201402L
+ struct NonLiteral {
+ NonLiteral() {}
+ };
+ NonLiteral nl;
+ constexpr NonLiteral &ExternNonLiteralVarDecl() {
+ extern NonLiteral nl;
+ return nl;
+ }
+ static_assert(&ExternNonLiteralVarDecl() == &nl, "");
+#endif
}
More information about the cfe-commits
mailing list