Author: Timm Baeder Date: 2026-02-04T14:30:10+01:00 New Revision: d26b035d6929f248d3c309b5f2b7b51694d5dc4b
URL: https://github.com/llvm/llvm-project/commit/d26b035d6929f248d3c309b5f2b7b51694d5dc4b DIFF: https://github.com/llvm/llvm-project/commit/d26b035d6929f248d3c309b5f2b7b51694d5dc4b.diff LOG: [clang][bytecode] Remove an incorrect assertion (#179644) There are situations where DiscardResult is set, but we still wish to emit a float value, e.g. when we will discard the result of an operation involving such a float value. Added: Modified: clang/lib/AST/ByteCode/Compiler.cpp clang/test/AST/ByteCode/complex.cpp Removed: ################################################################################ diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp index 3bc69716e8ef9..e563c0e3bb64f 100644 --- a/clang/lib/AST/ByteCode/Compiler.cpp +++ b/clang/lib/AST/ByteCode/Compiler.cpp @@ -7588,8 +7588,6 @@ bool Compiler<Emitter>::emitDummyPtr(const DeclTy &D, const Expr *E) { template <class Emitter> bool Compiler<Emitter>::emitFloat(const APFloat &F, const Expr *E) { - assert(!DiscardResult && "Should've been checked before"); - if (Floating::singleWord(F.getSemantics())) return this->emitConstFloat(Floating(F), E); diff --git a/clang/test/AST/ByteCode/complex.cpp b/clang/test/AST/ByteCode/complex.cpp index 9bf000d65466c..68a8e78d5b25b 100644 --- a/clang/test/AST/ByteCode/complex.cpp +++ b/clang/test/AST/ByteCode/complex.cpp @@ -1,5 +1,5 @@ // RUN: %clang_cc1 -fexperimental-new-constant-interpreter -verify=both,expected -Wno-unused-value %s -// RUN: %clang_cc1 -verify=both,ref -Wno-unused-value %s +// RUN: %clang_cc1 -verify=both,ref -Wno-unused-value %s constexpr _Complex double z1 = {1.0, 2.0}; static_assert(__real(z1) == 1.0, ""); @@ -131,6 +131,11 @@ static_assert(ignored() == 0, ""); static_assert((int)I1 == 1, ""); static_assert((float)D == 1.0f, ""); + +void ignoredEmitFloat() { + (1.f / (2.f + 3i), 4.f); +} + static_assert(__real((_Complex unsigned)5) == 5); static_assert(__imag((_Complex unsigned)5) == 0); _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
