diff options
| author | Sirraide <aeternalmail@gmail.com> | 2024-04-14 12:30:01 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-04-14 12:30:01 +0200 |
| commit | ef164cee90477e294ff692209b4cf97a0e1958ed (patch) | |
| tree | 3c287ecad68abfcc42764475fb6906c1da856afc /clang/lib/Sema/SemaInit.cpp | |
| parent | ed06b847d4e77d0b81fa6b095366bb070db57846 (diff) | |
| download | llvm-ef164cee90477e294ff692209b4cf97a0e1958ed.zip llvm-ef164cee90477e294ff692209b4cf97a0e1958ed.tar.gz llvm-ef164cee90477e294ff692209b4cf97a0e1958ed.tar.bz2 | |
[Clang] [C++26] Implement P2573R2: `= delete("should have a reason");` (#86526)
This implements support for the `= delete("message")` syntax that was
only just added to C++26
([P2573R2](https://isocpp.org/files/papers/P2573R2.html#proposal-scope)).
Diffstat (limited to 'clang/lib/Sema/SemaInit.cpp')
| -rw-r--r-- | clang/lib/Sema/SemaInit.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp index 6b8ce0f..fb7a80a 100644 --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -9763,12 +9763,15 @@ bool InitializationSequence::Diagnose(Sema &S, break; } case OR_Deleted: { - S.Diag(Kind.getLocation(), diag::err_typecheck_deleted_function) - << OnlyArg->getType() << DestType.getNonReferenceType() - << Args[0]->getSourceRange(); OverloadCandidateSet::iterator Best; OverloadingResult Ovl = FailedCandidateSet.BestViableFunction(S, Kind.getLocation(), Best); + + StringLiteral *Msg = Best->Function->getDeletedMessage(); + S.Diag(Kind.getLocation(), diag::err_typecheck_deleted_function) + << OnlyArg->getType() << DestType.getNonReferenceType() + << (Msg != nullptr) << (Msg ? Msg->getString() : StringRef()) + << Args[0]->getSourceRange(); if (Ovl == OR_Deleted) { S.NoteDeletedFunction(Best->Function); } else { @@ -10027,9 +10030,12 @@ bool InitializationSequence::Diagnose(Sema &S, << llvm::to_underlying( S.getSpecialMember(cast<CXXMethodDecl>(Best->Function))) << DestType << ArgsRange; - else + else { + StringLiteral *Msg = Best->Function->getDeletedMessage(); S.Diag(Kind.getLocation(), diag::err_ovl_deleted_init) - << DestType << ArgsRange; + << DestType << (Msg != nullptr) + << (Msg ? Msg->getString() : StringRef()) << ArgsRange; + } S.NoteDeletedFunction(Best->Function); break; @@ -11061,6 +11067,9 @@ QualType Sema::DeduceTemplateSpecializationFromInitializer( } case OR_Deleted: { + // FIXME: There are no tests for this diagnostic, and it doesn't seem + // like we ever get here; attempts to trigger this seem to yield a + // generic c'all to deleted function' diagnostic instead. Diag(Kind.getLocation(), diag::err_deduced_class_template_deleted) << TemplateName; NoteDeletedFunction(Best->Function); |
