Author: keinflue Date: 2026-03-24T10:19:43-04:00 New Revision: ef6172f32757aff6e4c4bb237ed3132d7ef24c12
URL: https://github.com/llvm/llvm-project/commit/ef6172f32757aff6e4c4bb237ed3132d7ef24c12 DIFF: https://github.com/llvm/llvm-project/commit/ef6172f32757aff6e4c4bb237ed3132d7ef24c12.diff LOG: [clang] Apply lvalue conversions to __builtin_classify_type argument (#175627) According to GCC documentation default argument promotion is applied to the argument, which includes the function-to-pointer and array-to-pointer lvalue conversions. This also implies checking of the argument for placeholder types. Fixes #175589. Added: Modified: clang/docs/ReleaseNotes.rst clang/lib/Sema/SemaChecking.cpp clang/test/SemaCXX/builtin-classify-type.cpp Removed: ################################################################################ diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 7a369fb01bdd9..a8897c707b9e6 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -358,6 +358,7 @@ Bug Fixes in This Version Bug Fixes to Compiler Builtins ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +- Fix a crash when passing an unresolved overload set to ``__builtin_classify_type``. (#GH175589) - Fixed a crash when calling `__builtin_allow_sanitize_check` with no arguments. (#GH183927) Bug Fixes to Attribute Support diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index 29add9d092e6b..00a664dfedbbc 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -3049,15 +3049,11 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID, if (BuiltinSetjmp(TheCall)) return ExprError(); break; - case Builtin::BI__builtin_classify_type: - if (checkArgCount(TheCall, 1)) - return true; - TheCall->setType(Context.IntTy); - break; case Builtin::BI__builtin_complex: if (BuiltinComplex(TheCall)) return ExprError(); break; + case Builtin::BI__builtin_classify_type: case Builtin::BI__builtin_constant_p: { if (checkArgCount(TheCall, 1)) return true; diff --git a/clang/test/SemaCXX/builtin-classify-type.cpp b/clang/test/SemaCXX/builtin-classify-type.cpp index 6bae9cd6b1dc0..dde08f6d0a9ba 100644 --- a/clang/test/SemaCXX/builtin-classify-type.cpp +++ b/clang/test/SemaCXX/builtin-classify-type.cpp @@ -1,8 +1,6 @@ // RUN: %clang_cc1 -fsyntax-only -verify -fblocks %s // RUN: %clang_cc1 -fsyntax-only -verify -fblocks %s -fexperimental-new-constant-interpreter -// expected-no-diagnostics - enum gcc_type_class { no_type_class = -1, void_type_class, integer_type_class, char_type_class, @@ -71,3 +69,18 @@ void foo() { int a23[__builtin_classify_type(bitint) == bitint_type_class ? 1 : -1]; } +namespace GH175589 { + struct C { + template<class T> + void f() {} + }; + // expected-error@+1 {{reference to overloaded function could not be resolved}} + int x1 = __builtin_classify_type(&C::f); + + void g(int); + void g(double); + // expected-error@+3 {{reference to overloaded function could not be resolved}} + // expected-note@-3 {{possible target for call}} + // expected-note@-3 {{possible target for call}} + int x2 = __builtin_classify_type(g); +} _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
