summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimm Bäder <tbaeder@redhat.com>2024-05-23 14:01:32 +0200
committerTimm Bäder <tbaeder@redhat.com>2024-05-23 14:01:32 +0200
commitfbd643fb22607b933a4e129ae86a7334b62c9b55 (patch)
tree1e32649a5a7966383b0d08f3005e2e5383a061b0
parent84729c9df30b29d5f4e903ad71235a6aa0c764d6 (diff)
[clang][Interp] Don't try to activate root pointers
No inline descriptor means we can't do that.
-rw-r--r--clang/lib/AST/Interp/Interp.h10
-rw-r--r--clang/test/AST/Interp/cxx98.cpp4
2 files changed, 10 insertions, 4 deletions
diff --git a/clang/lib/AST/Interp/Interp.h b/clang/lib/AST/Interp/Interp.h
index fc496b66445a..bcb6fb4d6521 100644
--- a/clang/lib/AST/Interp/Interp.h
+++ b/clang/lib/AST/Interp/Interp.h
@@ -1335,17 +1335,19 @@ inline bool GetPtrThisBase(InterpState &S, CodePtr OpPC, uint32_t Off) {
inline bool FinishInitPop(InterpState &S, CodePtr OpPC) {
const Pointer &Ptr = S.Stk.pop<Pointer>();
- if (Ptr.canBeInitialized())
+ if (Ptr.canBeInitialized()) {
Ptr.initialize();
- Ptr.activate();
+ Ptr.activate();
+ }
return true;
}
inline bool FinishInit(InterpState &S, CodePtr OpPC) {
const Pointer &Ptr = S.Stk.peek<Pointer>();
- if (Ptr.canBeInitialized())
+ if (Ptr.canBeInitialized()) {
Ptr.initialize();
- Ptr.activate();
+ Ptr.activate();
+ }
return true;
}
diff --git a/clang/test/AST/Interp/cxx98.cpp b/clang/test/AST/Interp/cxx98.cpp
index be81735329db..e68e4dbc8d74 100644
--- a/clang/test/AST/Interp/cxx98.cpp
+++ b/clang/test/AST/Interp/cxx98.cpp
@@ -50,3 +50,7 @@ _Static_assert(c0_test == 0, "");
int a = 0; // both-note {{declared here}}
_Static_assert(a == 0, ""); // both-error {{static assertion expression is not an integral constant expression}} \
// both-note {{read of non-const variable 'a' is not allowed in a constant expression}}
+
+struct SelfReference { SelfReference &r; };
+extern SelfReference self_reference_1;
+SelfReference self_reference_2 = {self_reference_1};