Skip to content

Commit 3889b27

Browse files
sdkrystianyuxuanchen1997
authored andcommitted
[Clang][AST] Don't use canonical type when checking dependence in Type::isOverloadable (#98563)
Summary: Fixes #97646. Test Plan: Reviewers: Subscribers: Tasks: Tags: Differential Revision: https://phabricator.intern.facebook.com/D60250645
1 parent 77077c6 commit 3889b27

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ Bug Fixes to Attribute Support
147147
Bug Fixes to C++ Support
148148
^^^^^^^^^^^^^^^^^^^^^^^^
149149

150+
- Fixed a crash when an expression with a dependent ``__typeof__`` type is used as the operand of a unary operator. (#GH97646)
151+
150152
Bug Fixes to AST Handling
151153
^^^^^^^^^^^^^^^^^^^^^^^^^
152154

clang/include/clang/AST/Type.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8434,7 +8434,7 @@ inline bool Type::isUndeducedType() const {
84348434
/// Determines whether this is a type for which one can define
84358435
/// an overloaded operator.
84368436
inline bool Type::isOverloadableType() const {
8437-
if (!CanonicalType->isDependentType())
8437+
if (!isDependentType())
84388438
return isRecordType() || isEnumeralType();
84398439
return !isArrayType() && !isFunctionType() && !isAnyPointerType() &&
84408440
!isMemberPointerType();

clang/test/SemaCXX/decltype.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,14 @@ namespace GH58674 {
139139
}
140140
}
141141

142+
namespace GH97646 {
143+
template<bool B>
144+
void f() {
145+
decltype(B) x = false;
146+
!x;
147+
}
148+
}
149+
142150
template<typename>
143151
class conditional {
144152
};

clang/test/SemaCXX/typeof_unqual.cpp renamed to clang/test/SemaCXX/typeof.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,11 @@
33
typeof_unqual(int) u = 12; // expected-error {{expected function body after function declarator}}
44
__typeof_unqual(int) _u = 12;
55
__typeof_unqual__(int) __u = 12;
6+
7+
namespace GH97646 {
8+
template<bool B>
9+
void f() {
10+
__typeof__(B) x = false;
11+
!x;
12+
}
13+
}

0 commit comments

Comments
 (0)