https://github.com/sdkrystian updated https://github.com/llvm/llvm-project/pull/98563
>From fde01e26873828b9ab2aa1eb2ae1e1b6106b66c6 Mon Sep 17 00:00:00 2001 From: Krystian Stasiowski <sdkryst...@gmail.com> Date: Thu, 11 Jul 2024 18:28:50 -0400 Subject: [PATCH 1/3] [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 25defea58c2dc..72723c7c56e07 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -8434,7 +8434,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 7c3f80603f70fd85c47695e94053988af0430fe7 Mon Sep 17 00:00:00 2001 From: Krystian Stasiowski <sdkryst...@gmail.com> Date: Mon, 22 Jul 2024 11:39:41 -0400 Subject: [PATCH 2/3] [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; +} >From 50362071a01d04b75f612447373783a50de9062e Mon Sep 17 00:00:00 2001 From: Krystian Stasiowski <sdkryst...@gmail.com> Date: Tue, 23 Jul 2024 13:58:16 -0400 Subject: [PATCH 3/3] [FOLD] address review comments --- clang/docs/ReleaseNotes.rst | 2 ++ clang/test/SemaCXX/decltype.cpp | 8 ++++++++ clang/test/SemaCXX/dependent-typeof.cpp | 10 ---------- clang/test/SemaCXX/{typeof_unqual.cpp => typeof.cpp} | 10 ++++++++++ 4 files changed, 20 insertions(+), 10 deletions(-) delete mode 100644 clang/test/SemaCXX/dependent-typeof.cpp rename clang/test/SemaCXX/{typeof_unqual.cpp => typeof.cpp} (59%) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index ac1de0db9ce48..14ad3a50c5ba2 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -138,6 +138,8 @@ Bug Fixes to Attribute Support Bug Fixes to C++ Support ^^^^^^^^^^^^^^^^^^^^^^^^ +- Fixed a crash when an expression with a dependent ``__typeof__`` type is used as the operand of a unary operator. (#GH97646) + Bug Fixes to AST Handling ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/clang/test/SemaCXX/decltype.cpp b/clang/test/SemaCXX/decltype.cpp index 96abb60836e40..d645a4df526dd 100644 --- a/clang/test/SemaCXX/decltype.cpp +++ b/clang/test/SemaCXX/decltype.cpp @@ -146,3 +146,11 @@ class conditional { // FIXME: The diagnostics here are produced twice. void foo(conditional<decltype((1),int>) { // expected-note 2 {{to match this '('}} expected-error {{expected ')'}} expected-note 2{{to match this '<'}} } // expected-error {{expected function body after function declarator}} expected-error 2 {{expected '>'}} expected-error {{expected ')'}} + +namespace GH97646 { + template<bool B> + void f() { + decltype(B) x = false; + !x; + } +} diff --git a/clang/test/SemaCXX/dependent-typeof.cpp b/clang/test/SemaCXX/dependent-typeof.cpp deleted file mode 100644 index abfbf4a24081e..0000000000000 --- a/clang/test/SemaCXX/dependent-typeof.cpp +++ /dev/null @@ -1,10 +0,0 @@ -// 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; -} diff --git a/clang/test/SemaCXX/typeof_unqual.cpp b/clang/test/SemaCXX/typeof.cpp similarity index 59% rename from clang/test/SemaCXX/typeof_unqual.cpp rename to clang/test/SemaCXX/typeof.cpp index 335e57995377c..dd5ca19a4dd8f 100644 --- a/clang/test/SemaCXX/typeof_unqual.cpp +++ b/clang/test/SemaCXX/typeof.cpp @@ -3,3 +3,13 @@ typeof_unqual(int) u = 12; // expected-error {{expected function body after function declarator}} __typeof_unqual(int) _u = 12; __typeof_unqual__(int) __u = 12; + +namespace GH97646 { + template<bool B> + void f() { + __typeof__(B) x = false; + __typeof_unqual__(B) y = false; + !x; + !y; + } +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits