llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) <details> <summary>Changes</summary> If S.noteUndefinedBehavior() returns true, we will continue evaluation and need a value on the stack. --- Full diff: https://github.com/llvm/llvm-project/pull/72658.diff 2 Files Affected: - (modified) clang/lib/AST/Interp/Interp.h (+5-1) - (modified) clang/test/AST/Interp/floats.cpp (+4) ``````````diff diff --git a/clang/lib/AST/Interp/Interp.h b/clang/lib/AST/Interp/Interp.h index 026a95d65488da9..ef09b957057cdcb 100644 --- a/clang/lib/AST/Interp/Interp.h +++ b/clang/lib/AST/Interp/Interp.h @@ -1619,7 +1619,11 @@ bool CastFloatingIntegral(InterpState &S, CodePtr OpPC) { QualType Type = E->getType(); S.CCEDiag(E, diag::note_constexpr_overflow) << F.getAPFloat() << Type; - return S.noteUndefinedBehavior(); + if (S.noteUndefinedBehavior()) { + S.Stk.push<T>(T(Result)); + return true; + } + return false; } S.Stk.push<T>(T(Result)); diff --git a/clang/test/AST/Interp/floats.cpp b/clang/test/AST/Interp/floats.cpp index e17167f5bf6dbbf..45c31c759e47fc6 100644 --- a/clang/test/AST/Interp/floats.cpp +++ b/clang/test/AST/Interp/floats.cpp @@ -39,6 +39,10 @@ constexpr float m = 5.0f / 0.0f; // ref-error {{must be initialized by a constan static_assert(~2.0f == 3, ""); // ref-error {{invalid argument type 'float' to unary expression}} \ // expected-error {{invalid argument type 'float' to unary expression}} + +typedef int tdb[(long long)4e20]; //expected-error {{variable length}} \ + //ref-error {{variable length}} + /// Initialized by a double. constexpr float df = 0.0; /// The other way around. `````````` </details> https://github.com/llvm/llvm-project/pull/72658 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits