diff options
author | Timm Bäder <tbaeder@redhat.com> | 2024-06-25 09:08:56 +0200 |
---|---|---|
committer | Timm Bäder <tbaeder@redhat.com> | 2024-06-25 09:09:49 +0200 |
commit | 8153773b23032177546944ec2524dce131b8a46e (patch) | |
tree | 94a381b4f06ef6df8e510baa5252f674e240b3c2 | |
parent | fa20184a8f336e4154f2ffeeeb8a538dc9462d9a (diff) | |
download | llvm-8153773b23032177546944ec2524dce131b8a46e.zip llvm-8153773b23032177546944ec2524dce131b8a46e.tar.gz llvm-8153773b23032177546944ec2524dce131b8a46e.tar.bz2 |
[clang][Interp] Fix returning primitive non-blockpointers
We can't deref() them, so return false here.
-rw-r--r-- | clang/lib/AST/Interp/Pointer.cpp | 2 | ||||
-rw-r--r-- | clang/test/AST/Interp/literals.cpp | 2 |
2 files changed, 3 insertions, 1 deletions
diff --git a/clang/lib/AST/Interp/Pointer.cpp b/clang/lib/AST/Interp/Pointer.cpp index d77cd89..4070d0c 100644 --- a/clang/lib/AST/Interp/Pointer.cpp +++ b/clang/lib/AST/Interp/Pointer.cpp @@ -347,7 +347,7 @@ std::optional<APValue> Pointer::toRValue(const Context &Ctx) const { Ty = AT->getValueType(); // Invalid pointers. - if (Ptr.isDummy() || !Ptr.isLive() || + if (Ptr.isDummy() || !Ptr.isLive() || !Ptr.isBlockPointer() || (!Ptr.isUnknownSizeArray() && Ptr.isOnePastEnd())) return false; diff --git a/clang/test/AST/Interp/literals.cpp b/clang/test/AST/Interp/literals.cpp index 5a29013..ef98b49 100644 --- a/clang/test/AST/Interp/literals.cpp +++ b/clang/test/AST/Interp/literals.cpp @@ -45,6 +45,8 @@ constexpr int Failed2 = Failed1 + 1; // both-error {{must be initialized by a co static_assert(Failed2 == 0, ""); // both-error {{not an integral constant expression}} \ // both-note {{initializer of 'Failed2' is not a constant expression}} +const int x = *(volatile int*)0x1234; + namespace ScalarTypes { constexpr int ScalarInitInt = int(); static_assert(ScalarInitInt == 0, ""); |