Author: Timm Bäder Date: 2024-02-28T14:27:25+01:00 New Revision: a2efb68906ec2bf7b55b464060c3713e395e68e5
URL: https://github.com/llvm/llvm-project/commit/a2efb68906ec2bf7b55b464060c3713e395e68e5 DIFF: https://github.com/llvm/llvm-project/commit/a2efb68906ec2bf7b55b464060c3713e395e68e5.diff LOG: [clang][Interp] Remove now faulty assertion We can call getBase() for pointers where Base != Offset as well, for example when we've added a constant to the Offset. Added: Modified: clang/lib/AST/Interp/Pointer.h clang/test/AST/Interp/cxx11.cpp Removed: ################################################################################ diff --git a/clang/lib/AST/Interp/Pointer.h b/clang/lib/AST/Interp/Pointer.h index fa2e03d71190f5..34ecdb967960d5 100644 --- a/clang/lib/AST/Interp/Pointer.h +++ b/clang/lib/AST/Interp/Pointer.h @@ -215,7 +215,6 @@ class Pointer { assert(Offset == PastEndMark && "cannot get base of a block"); return Pointer(Pointee, Base, 0); } - assert(Offset == Base && "not an inner field"); unsigned NewBase = Base - getInlineDesc()->Offset; return Pointer(Pointee, NewBase, NewBase); } diff --git a/clang/test/AST/Interp/cxx11.cpp b/clang/test/AST/Interp/cxx11.cpp index 0a1e0f3fd28e9d..29098ea694c688 100644 --- a/clang/test/AST/Interp/cxx11.cpp +++ b/clang/test/AST/Interp/cxx11.cpp @@ -22,3 +22,9 @@ int array2[recurse2]; // both-warning {{variable length arrays in C++}} \ // both-note {{initializer of 'recurse2' is not a constant expression}} \ // expected-error {{variable length array declaration not allowed at file scope}} \ // ref-warning {{variable length array folded to constant array as an extension}} + +struct S { + int m; +}; +constexpr S s = { 5 }; +constexpr const int *p = &s.m + 1; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits