llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) <details> <summary>Changes</summary> Fixes #https://github.com/llvm/llvm-project/issues/216294 --- Full diff: https://github.com/llvm/llvm-project/pull/216929.diff 2 Files Affected: - (modified) clang/lib/Sema/SemaChecking.cpp (+7-1) - (modified) clang/test/AST/ByteCode/builtin-functions.cpp (+11) ``````````diff 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 { `````````` </details> https://github.com/llvm/llvm-project/pull/216929 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
