Skip to content
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

[Clang] Implement CWG2518 - static_assert(false) [v6.32] #15753

Merged
merged 1 commit into from
Jun 5, 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
2 changes: 2 additions & 0 deletions interpreter/llvm-project/clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ sections with improvements to Clang's support for those languages.

C++ Language Changes
--------------------
- Implemented `CWG2518 <https://wg21.link/CWG2518>`_ which allows ``static_assert(false)``
to not be ill-formed when its condition is evaluated in the context of a template definition.

C++20 Feature Support
^^^^^^^^^^^^^^^^^^^^^
Expand Down
12 changes: 10 additions & 2 deletions interpreter/llvm-project/clang/lib/Sema/SemaDeclCXX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16802,7 +16802,14 @@ Decl *Sema::BuildStaticAssertDeclaration(SourceLocation StaticAssertLoc,
FoldKind).isInvalid())
Failed = true;

if (!Failed && !Cond) {
// CWG2518
// [dcl.pre]/p10 If [...] the expression is evaluated in the context of a
// template definition, the declaration has no effect.
bool InTemplateDefinition =
getLangOpts().CPlusPlus && CurContext->isDependentContext();

if (!Failed && !Cond && !InTemplateDefinition) {

SmallString<256> MsgBuffer;
llvm::raw_svector_ostream Msg(MsgBuffer);
if (AssertMessage) {
Expand Down Expand Up @@ -16833,7 +16840,8 @@ Decl *Sema::BuildStaticAssertDeclaration(SourceLocation StaticAssertLoc,
DiagnoseStaticAssertDetails(InnerCond);
} else {
Diag(StaticAssertLoc, diag::err_static_assert_failed)
<< !AssertMessage << Msg.str() << AssertExpr->getSourceRange();
<< !AssertMessage << Msg.str() << AssertExpr->getSourceRange();
PrintContextStack();
}
Failed = true;
}
Expand Down
2 changes: 1 addition & 1 deletion interpreter/llvm-project/clang/www/cxx_dr_status.html
Original file line number Diff line number Diff line change
Expand Up @@ -14915,7 +14915,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
<td><a href="https://wg21.link/cwg2518">2518</a></td>
<td>review</td>
<td>Conformance requirements and <TT>#error</TT>/<TT>#warning</TT></td>
<td align="center">Not resolved</td>
<td class="unreleased" align="center">Clang 17</td>
</tr>
<tr class="open" id="2519">
<td><a href="https://wg21.link/cwg2519">2519</a></td>
Expand Down
2 changes: 1 addition & 1 deletion interpreter/llvm-project/llvm-project.tag
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ROOT-llvm16-20240402-01
ROOT-llvm16-20240604-01
Loading