Skip to content

Commit 96f4e2a

Browse files
committed
[clang] SourceLocIdentKind::Function should not be dependent
1 parent a6929db commit 96f4e2a

File tree

3 files changed

+35
-2
lines changed

3 files changed

+35
-2
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -846,6 +846,7 @@ Bug Fixes to C++ Support
846846
- Fix a crash caused by improper use of ``__array_extent``. (#GH80474)
847847
- Fixed several bugs in capturing variables within unevaluated contexts. (#GH63845), (#GH67260), (#GH69307),
848848
(#GH88081), (#GH89496), (#GH90669) and (#GH91633).
849+
- Fix a crash when SourceLocExpr instantiated in a dependent context. (GH80210).
849850

850851
Bug Fixes to AST Handling
851852
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/include/clang/AST/Expr.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4786,8 +4786,6 @@ class SourceLocExpr final : public Expr {
47864786

47874787
static bool MayBeDependent(SourceLocIdentKind Kind) {
47884788
switch (Kind) {
4789-
case SourceLocIdentKind::Function:
4790-
case SourceLocIdentKind::FuncSig:
47914789
case SourceLocIdentKind::SourceLocStruct:
47924790
return true;
47934791
default:

clang/test/CodeGenCXX/PR80210.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// RUN: %clang_cc1 -std=c++20 %s -emit-llvm -o /dev/null -verify -triple %itanium_abi_triple
2+
// RUN: %clang_cc1 -std=c++20 %s -emit-llvm -o /dev/null -verify -triple %ms_abi_triple
3+
4+
// expected-no-diagnostics
5+
6+
struct BasicPersistent;
7+
template <typename> BasicPersistent &&__declval(int);
8+
template <typename _Tp> auto declval() -> decltype(__declval<_Tp>(0));
9+
template <typename _Tp> _Tp forward;
10+
template <typename _Tp, typename... _Args>
11+
auto construct_at(_Tp *, _Args...) -> decltype(new _Tp(declval<_Args>()...)) {return 0;}
12+
template <typename> struct allocator;
13+
template <typename> struct allocator_traits;
14+
template <typename _Tp> struct allocator_traits<allocator<_Tp>> {
15+
using pointer = _Tp *;
16+
template <typename _Up, typename... _Args>
17+
static void construct(_Up __p, _Args...) {
18+
construct_at(__p, forward<_Args>...);
19+
}
20+
};
21+
struct __alloc_traits : allocator_traits<allocator<BasicPersistent>> {
22+
} push_back___x;
23+
__alloc_traits::pointer _M_impl_0;
24+
template <typename... _Args> void emplace_back(_Args...) {
25+
__alloc_traits::construct(_M_impl_0, forward<_Args>...);
26+
}
27+
struct SourceLocation {
28+
static SourceLocation Current(const char * = __builtin_FUNCTION());
29+
};
30+
struct BasicPersistent {
31+
BasicPersistent(BasicPersistent &&,
32+
SourceLocation = SourceLocation::Current());
33+
};
34+
void CFXJSE_EngineAddObjectToUpArray() { emplace_back(push_back___x); }

0 commit comments

Comments
 (0)