diff options
author | Timm Baeder <tbaeder@redhat.com> | 2025-04-25 07:43:33 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-04-25 07:43:33 +0200 |
commit | 3b58a60086cb755fe40cb90a73d27a83d44ce766 (patch) | |
tree | 269a7f260938e40b371dee4d86a92c44f2c1050c /clang/lib/AST/ByteCode/Interp.cpp | |
parent | 6d99d1a4a93564ab7a128c269b2c55dcbd4f9570 (diff) | |
download | llvm-3b58a60086cb755fe40cb90a73d27a83d44ce766.zip llvm-3b58a60086cb755fe40cb90a73d27a83d44ce766.tar.gz llvm-3b58a60086cb755fe40cb90a73d27a83d44ce766.tar.bz2 |
[clang][bytecode] Allow forming pointers to fields of extern globals (#137211)
This should be fine as long as we're not reading from it.
Note that this regresses
CXX/special/class.init/class.inhctor.init/p1.cpp, which used to work
fine with the bytecode interpreter.
That's because this code now fails:
```c++
struct Param;
struct A {
constexpr A(Param);
int a;
};
struct B : A { B(); using A::A; int b = 2; };
struct Wrap1 : B { constexpr Wrap1(); };
struct Wrap2 : Wrap1 {};
extern const Wrap2 b;
struct Param {
constexpr Param(int c) : n(4 * b.a + b.b + c) {}
int n;
};
```
and reports that the Param() constructor is never a valid constant
expression. But that's true and the current interpeter should report
that as well. It also fails when calling at compile time.
Diffstat (limited to 'clang/lib/AST/ByteCode/Interp.cpp')
-rw-r--r-- | clang/lib/AST/ByteCode/Interp.cpp | 2 |
1 files changed, 0 insertions, 2 deletions
diff --git a/clang/lib/AST/ByteCode/Interp.cpp b/clang/lib/AST/ByteCode/Interp.cpp index 6f277a7..23fd894 100644 --- a/clang/lib/AST/ByteCode/Interp.cpp +++ b/clang/lib/AST/ByteCode/Interp.cpp @@ -1323,8 +1323,6 @@ static bool getField(InterpState &S, CodePtr OpPC, const Pointer &Ptr, !CheckNull(S, OpPC, Ptr, CSK_Field)) return false; - if (!CheckExtern(S, OpPC, Ptr)) - return false; if (!CheckRange(S, OpPC, Ptr, CSK_Field)) return false; if (!CheckArray(S, OpPC, Ptr)) |