Skip to content

Commit 8b15403

Browse files
sdkrystianahatanaka
authored andcommitted
[Clang][AST] Don't use canonical type when checking dependence in Type::isOverloadable (llvm#98563)
Fixes llvm#97646. Conflicts: clang/docs/ReleaseNotes.rst clang/test/SemaCXX/decltype.cpp
1 parent c2f3689 commit 8b15403

File tree

4 files changed

+18
-1
lines changed

4 files changed

+18
-1
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,6 +1123,7 @@ Bug Fixes to C++ Support
11231123
- Fixed assertion failure by skipping the analysis of an invalid field declaration. (#GH99868)
11241124
- Fix an issue with dependent source location expressions (#GH106428), (#GH81155), (#GH80210), (#GH85373)
11251125
- Fix handling of ``_`` as the name of a lambda's init capture variable. (#GH107024)
1126+
- Fixed a crash when an expression with a dependent ``__typeof__`` type is used as the operand of a unary operator. (#GH97646)
11261127

11271128

11281129
Bug Fixes to AST Handling

clang/include/clang/AST/Type.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8452,7 +8452,7 @@ inline bool Type::isUndeducedType() const {
84528452
/// Determines whether this is a type for which one can define
84538453
/// an overloaded operator.
84548454
inline bool Type::isOverloadableType() const {
8455-
if (!CanonicalType->isDependentType())
8455+
if (!isDependentType())
84568456
return isRecordType() || isEnumeralType();
84578457
return !isArrayType() && !isFunctionType() && !isAnyPointerType() &&
84588458
!isMemberPointerType();

clang/test/SemaCXX/decltype.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,14 @@ static_assert(A<int>().f<int>() != 0, ""); // expected-error {{static assertion
164164
// expected-note@-1 {{expression evaluates to '0 != 0'}}
165165
}
166166

167+
namespace GH97646 {
168+
template<bool B>
169+
void f() {
170+
decltype(B) x = false;
171+
!x;
172+
}
173+
}
174+
167175
template<typename>
168176
class conditional {
169177
};

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)