llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) <details> <summary>Changes</summary> --- Full diff: https://github.com/llvm/llvm-project/pull/154496.diff 2 Files Affected: - (modified) clang/lib/AST/ByteCode/EvalEmitter.cpp (+1-3) - (modified) clang/test/AST/ByteCode/cxx98.cpp (+20-4) ``````````diff diff --git a/clang/lib/AST/ByteCode/EvalEmitter.cpp b/clang/lib/AST/ByteCode/EvalEmitter.cpp index 68f46c113ff28..1ebadae811bdf 100644 --- a/clang/lib/AST/ByteCode/EvalEmitter.cpp +++ b/clang/lib/AST/ByteCode/EvalEmitter.cpp @@ -213,10 +213,8 @@ template <> bool EvalEmitter::emitRet<PT_Ptr>(const SourceInfo &Info) { if (!Ptr.isZero() && !Ptr.isDereferencable()) return false; - if (S.getLangOpts().CPlusPlus11 && Ptr.isBlockPointer() && - !CheckFinalLoad(S, OpPC, Ptr)) { + if (!Ptr.isZero() && !CheckFinalLoad(S, OpPC, Ptr)) return false; - } // Never allow reading from a non-const pointer, unless the memory // has been created in this evaluation. diff --git a/clang/test/AST/ByteCode/cxx98.cpp b/clang/test/AST/ByteCode/cxx98.cpp index c17049b01c1da..1150a4e41edc1 100644 --- a/clang/test/AST/ByteCode/cxx98.cpp +++ b/clang/test/AST/ByteCode/cxx98.cpp @@ -18,13 +18,12 @@ template struct C<cval>; /// FIXME: This example does not get properly diagnosed in the new interpreter. extern const int recurse1; -const int recurse2 = recurse1; // both-note {{declared here}} +const int recurse2 = recurse1; // ref-note {{declared here}} const int recurse1 = 1; int array1[recurse1]; int array2[recurse2]; // ref-warning 2{{variable length array}} \ - // both-note {{initializer of 'recurse2' is not a constant expression}} \ - // expected-warning {{variable length array}} \ - // expected-error {{variable length array}} + // ref-note {{initializer of 'recurse2' is not a constant expression}} \ + // expected-warning 2{{variable length array}} int NCI; // both-note {{declared here}} int NCIA[NCI]; // both-warning {{variable length array}} \ @@ -64,3 +63,20 @@ const int b = 1 / 0; // both-warning {{division by zero is undefined}} \ // both-note {{declared here}} _Static_assert(b, ""); // both-error {{not an integral constant expression}} \ // both-note {{initializer of 'b' is not a constant expression}} + +#ifdef __SIZEOF_INT128__ +/// The if statement tries an ltor conversion on an inactive union member. +union InactiveReadUnion{ + int a; + __uint128_t n; +}; + +int inactiveRead(void) { + const InactiveReadUnion U = {1}; + + if (U.n) + return 1; + + return 0; +} +#endif `````````` </details> https://github.com/llvm/llvm-project/pull/154496 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits