Skip to content

[clang] Fix crash in concept deprecation #98622

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions clang/lib/Sema/SemaDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7416,10 +7416,10 @@ NamedDecl *Sema::ActOnVariableDeclarator(
tryToFixVariablyModifiedVarType(TInfo, R, D.getIdentifierLoc(),
/*DiagID=*/0);

if (const AutoType *AutoT = R->getAs<AutoType>())
CheckConstrainedAuto(
AutoT,
TInfo->getTypeLoc().getContainedAutoTypeLoc().getConceptNameLoc());
if (AutoTypeLoc TL = TInfo->getTypeLoc().getContainedAutoTypeLoc()) {
const AutoType *AT = TL.getTypePtr();
CheckConstrainedAuto(AT, TL.getConceptNameLoc());
}

bool IsMemberSpecialization = false;
bool IsVariableTemplateSpecialization = false;
Expand Down
9 changes: 4 additions & 5 deletions clang/lib/Sema/SemaType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6308,11 +6308,10 @@ TypeResult Sema::ActOnTypeName(Declarator &D) {
CheckExtraCXXDefaultArguments(D);
}

if (const AutoType *AutoT = T->getAs<AutoType>())
CheckConstrainedAuto(
AutoT,
TInfo->getTypeLoc().getContainedAutoTypeLoc().getConceptNameLoc());

if (AutoTypeLoc TL = TInfo->getTypeLoc().getContainedAutoTypeLoc()) {
const AutoType *AT = TL.getTypePtr();
CheckConstrainedAuto(AT, TL.getConceptNameLoc());
}
return CreateParsedType(T, TInfo);
}

Expand Down
9 changes: 9 additions & 0 deletions clang/test/CXX/drs/cwg24xx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,15 @@ auto h() -> C auto {
C auto foo = T();
// expected-warning@-1 {{'C' is deprecated}}
// expected-note@#cwg2428-C {{'C' has been explicitly marked deprecated here}}
C auto *bar = T();
// expected-warning@-1 {{'C' is deprecated}}
// expected-note@#cwg2428-C {{'C' has been explicitly marked deprecated here}}
C auto &baz = T();
// expected-warning@-1 {{'C' is deprecated}}
// expected-note@#cwg2428-C {{'C' has been explicitly marked deprecated here}}
C auto &&quux = T();
// expected-warning@-1 {{'C' is deprecated}}
// expected-note@#cwg2428-C {{'C' has been explicitly marked deprecated here}}
return foo;
}
#endif
Expand Down
9 changes: 9 additions & 0 deletions clang/test/SemaCXX/cxx-deprecated.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,13 @@ template <C T>
// expected-warning@-1 {{'C' is deprecated}}
// expected-note@#C {{'C' has been explicitly marked deprecated here}}
void f();

namespace GH98164 {
template <int>
auto b() = delete; // #b

decltype(b<0>()) x;
// expected-error@-1 {{call to deleted function 'b'}}
// expected-note@#b {{candidate function [with $0 = 0] has been explicitly deleted}}
} // namespace GH98164
} // namespace cxx20_concept
Loading