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/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(); diff --git a/clang/test/SemaCXX/decltype.cpp b/clang/test/SemaCXX/decltype.cpp index 96abb60836e40..9961c5e2bd918 100644 --- a/clang/test/SemaCXX/decltype.cpp +++ b/clang/test/SemaCXX/decltype.cpp @@ -139,6 +139,14 @@ namespace GH58674 { } } +namespace GH97646 { + template + void f() { + decltype(B) x = false; + !x; + } +} + template class conditional { }; diff --git a/clang/test/SemaCXX/typeof_unqual.cpp b/clang/test/SemaCXX/typeof.cpp similarity index 68% rename from clang/test/SemaCXX/typeof_unqual.cpp rename to clang/test/SemaCXX/typeof.cpp index 335e57995377c..421cfc59f5311 100644 --- a/clang/test/SemaCXX/typeof_unqual.cpp +++ b/clang/test/SemaCXX/typeof.cpp @@ -3,3 +3,11 @@ 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 + void f() { + __typeof__(B) x = false; + !x; + } +}