[clang] [clang] Apply lvalue conversions to __builtin_classify_type argument (PR #175627)
via cfe-commits
cfe-commits at lists.llvm.org
Sat Mar 21 16:13:38 PDT 2026
https://github.com/keinflue updated https://github.com/llvm/llvm-project/pull/175627
>From cbec0862149a817a3a6bb975b585330880cfe876 Mon Sep 17 00:00:00 2001
From: keinflue <keinflue at posteo.de>
Date: Mon, 12 Jan 2026 20:23:47 +0100
Subject: [PATCH 1/2] [clang] Apply lvalue conversions to
__builtin_classify_type argument
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.
---
clang/docs/ReleaseNotes.rst | 1 +
clang/lib/Sema/SemaChecking.cpp | 6 +-----
clang/test/SemaCXX/builtin-classify-type.cpp | 17 +++++++++++++++--
3 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 411cc348d4caf..42a3481373acc 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -557,6 +557,7 @@ Bug Fixes to Compiler Builtins
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Fix an ambiguous reference to the builtin `type_info` (available when using
`-fms-compatibility`) with modules. (#GH38400)
+- Fix a crash when passing an unresolved overload set to ``__builtin_classify_type``. (#GH175589)
Bug Fixes to Attribute Support
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index ba4b25961d70d..ae81393cabc71 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -2880,15 +2880,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 at +1 {{reference to overloaded function could not be resolved}}
+ int x1 = __builtin_classify_type(&C::f);
+
+ void g(int);
+ void g(double);
+ // expected-error at +3 {{reference to overloaded function could not be resolved}}
+ // expected-note at -3 {{possible target for call}}
+ // expected-note at -3 {{possible target for call}}
+ int x2 = __builtin_classify_type(g);
+}
>From 7ea077ca088c266ac6bccd083a166516a2827812 Mon Sep 17 00:00:00 2001
From: keinflue <keinflue at posteo.de>
Date: Sat, 21 Mar 2026 23:13:26 +0000
Subject: [PATCH 2/2] Fix incorrect merge conflict resolution.
---
clang/docs/ReleaseNotes.rst | 2 --
1 file changed, 2 deletions(-)
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 797a3b8a6a125..8af473bd5c816 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -342,8 +342,6 @@ Bug Fixes in This Version
Bug Fixes to Compiler Builtins
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-- Fix an ambiguous reference to the builtin `type_info` (available when using
- `-fms-compatibility`) with modules. (#GH38400)
- 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)
More information about the cfe-commits
mailing list