[clang] [Clang][AST] Don't use canonical type when checking dependence in Type::isOverloadable (PR #98563)

Krystian Stasiowski via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 23 02:31:13 PDT 2024


https://github.com/sdkrystian updated https://github.com/llvm/llvm-project/pull/98563

>From 5cefddec13ca2bafb58a6f714fd2bef435166c8d Mon Sep 17 00:00:00 2001
From: Krystian Stasiowski <sdkrystian at gmail.com>
Date: Thu, 11 Jul 2024 18:28:50 -0400
Subject: [PATCH 1/2] [Clang][AST] Don't use canonical type when checking
 dependence in Type::isOverloadable

---
 clang/include/clang/AST/Type.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index a2194361abd53..8b236af78ea22 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -8438,7 +8438,7 @@ inline bool Type::isUndeducedType() const {
 /// Determines whether this is a type for which one can define
 /// an overloaded operator.
 inline bool Type::isOverloadableType() const {
-  if (!CanonicalType->isDependentType())
+  if (!isDependentType())
     return isRecordType() || isEnumeralType();
   return !isArrayType() && !isFunctionType() && !isAnyPointerType() &&
          !isMemberPointerType();

>From d60492d7b6be408a49df1b183a1a48169fd4d03c Mon Sep 17 00:00:00 2001
From: Krystian Stasiowski <sdkrystian at gmail.com>
Date: Mon, 22 Jul 2024 11:39:41 -0400
Subject: [PATCH 2/2] [FOLD] add tests

---
 clang/test/SemaCXX/dependent-typeof.cpp | 10 ++++++++++
 1 file changed, 10 insertions(+)
 create mode 100644 clang/test/SemaCXX/dependent-typeof.cpp

diff --git a/clang/test/SemaCXX/dependent-typeof.cpp b/clang/test/SemaCXX/dependent-typeof.cpp
new file mode 100644
index 0000000000000..abfbf4a24081e
--- /dev/null
+++ b/clang/test/SemaCXX/dependent-typeof.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+template<bool B>
+void f() {
+  decltype(B) x = false;
+  __typeof__(B) y = false;
+  !x;
+  !y;
+}



More information about the cfe-commits mailing list