https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/216929
Fixes #https://github.com/llvm/llvm-project/issues/216294 >From 6c7646b2649b4e705e9068dcdbbf38ef99d112ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= <[email protected]> Date: Tue, 18 Aug 2026 08:54:16 +0200 Subject: [PATCH] [clang][Sema] Do lvalue-to-rvalue conversion on isfpclass Mask arg Fixes #https://github.com/llvm/llvm-project/issues/216294 --- clang/lib/Sema/SemaChecking.cpp | 8 +++++++- clang/test/AST/ByteCode/builtin-functions.cpp | 11 +++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index 3e6266b8ac542..d0190364bb209 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -6481,9 +6481,15 @@ bool Sema::BuiltinFPClassification(CallExpr *TheCall, unsigned NumArgs, // __builtin_isfpclass has integer parameter that specify test mask. It is // passed in (...), so it should be analyzed completely here. - if (IsFPClass) + if (IsFPClass) { if (BuiltinConstantArgRange(TheCall, 1, 0, llvm::fcAllFlags)) return true; + ExprResult MaskRes = + DefaultFunctionArrayLvalueConversion(TheCall->getArg(NumArgs - 1)); + if (!MaskRes.isUsable()) + return true; + TheCall->setArg(NumArgs - 1, MaskRes.get()); + } // TODO: enable this code to all classification functions. if (IsFPClass) { diff --git a/clang/test/AST/ByteCode/builtin-functions.cpp b/clang/test/AST/ByteCode/builtin-functions.cpp index 87ffb1cc5b609..c6a1a4f38a803 100644 --- a/clang/test/AST/ByteCode/builtin-functions.cpp +++ b/clang/test/AST/ByteCode/builtin-functions.cpp @@ -339,6 +339,17 @@ namespace isfpclass { char isfpclass_snan_1 [!__builtin_isfpclass(__builtin_nans(""), 0x0002) ? 1 : -1]; // fcQNan char isfpclass_snan_2 [__builtin_isfpclass(__builtin_nansl(""), 0x0207) ? 1 : -1]; // ~fcFinite char isfpclass_snan_3 [!__builtin_isfpclass(__builtin_nans(""), 0x01F8) ? 1 : -1]; // fcFinite + + + int foo() { + int a = 1; // #decla + char A[__builtin_isfpclass(1.0f, a)]; +#if __cplusplus >= 202002L + // both-warning@-2 {{variable length arrays}} \ + // both-note@-2 {{read of non-const variable 'a'}} \ + // both-note@#decla {{declared here}} +#endif + } } namespace signbit { _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
