[PATCH] D122249: [Clang] Add a compatibiliy warning for non-literals in constexpr.

2022-03-30 Thread Corentin Jabot via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rG0550601d1801: [Clang] Add a compatibiliy warning for non-literals in constexpr. (authored by cor3ntin). Repository: rG LLVM Github Monorepo

[PATCH] D122249: [Clang] Add a compatibiliy warning for non-literals in constexpr.

2022-03-30 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment. I thing to support the template case, we would have to modify `TemplateDeclInstantiator::VisitVarDecl` - which seems the best way to have a diagnostic without running through the whole function AST twice. However, there is currently no check of any sort there so it

[PATCH] D122249: [Clang] Add a compatibiliy warning for non-literals in constexpr.

2022-03-30 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision. aaron.ballman added a comment. LGTM Comment at: clang/lib/Sema/SemaDeclCXX.cpp:1905 +if (SemaRef.LangOpts.CPlusPlus2b) { + if (!VD->getType()->isLiteralType(SemaRef.Context)) +SemaRef.Diag(VD->getLocation(),

[PATCH] D122249: [Clang] Add a compatibiliy warning for non-literals in constexpr.

2022-03-30 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 419158. cor3ntin added a comment. Add braces Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D122249/new/ https://reviews.llvm.org/D122249 Files: clang/include/clang/Basic/DiagnosticSemaKinds.td

[PATCH] D122249: [Clang] Add a compatibiliy warning for non-literals in constexpr.

2022-03-30 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast accepted this revision. hubert.reinterpretcast added a comment. This revision is now accepted and ready to land. This LGTM (with minor comment). Please wait for Aaron to respond re: the handling of template instantiations. Comment at:

[PATCH] D122249: [Clang] Add a compatibiliy warning for non-literals in constexpr.

2022-03-30 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 419120. cor3ntin added a comment. - Add a commebt to clarify which diagnostic message is being printed, as per Aaron suggestion. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D122249/new/

[PATCH] D122249: [Clang] Add a compatibiliy warning for non-literals in constexpr.

2022-03-23 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments. Comment at: clang/lib/Sema/SemaDeclCXX.cpp:1905-1907 + CheckLiteralType(SemaRef, Kind, VD->getLocation(), VD->getType(), + diag::warn_cxx20_compat_constexpr_var, +

[PATCH] D122249: [Clang] Add a compatibiliy warning for non-literals in constexpr.

2022-03-23 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 417640. cor3ntin added a comment. After talks with Aaron, I'm using CheckLiteralType in all cases, which adds notes about why a type is not literal. We still need to branch on CPlusPlus2b because the diagnostics take a variable number of arguments, and I'd

[PATCH] D122249: [Clang] Add a compatibiliy warning for non-literals in constexpr.

2022-03-23 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added inline comments. Comment at: clang/lib/Sema/SemaDeclCXX.cpp:1905 +if (SemaRef.LangOpts.CPlusPlus2b) { + if (!VD->getType()->isLiteralType(SemaRef.Context)) +SemaRef.Diag(VD->getLocation(), aaron.ballman wrote: >

[PATCH] D122249: [Clang] Add a compatibiliy warning for non-literals in constexpr.

2022-03-23 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment. In D122249#3402331 , @cor3ntin wrote: > - Fix test > - Add a comment explaining why we do not use CheckLiteralType > > @aaron,ballman I completely missed that...! No worries! > However, CheckLiteralType does a bunch of

[PATCH] D122249: [Clang] Add a compatibiliy warning for non-literals in constexpr.

2022-03-23 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 417586. cor3ntin added a comment. - Fix test - Add a comment explaining why we do not use CheckLiteralType @aaron,ballman I completely missed that...! However, CheckLiteralType does a bunch of tests that we do not need to diagnose *why* a type is not

[PATCH] D122249: [Clang] Add a compatibiliy warning for non-literals in constexpr.

2022-03-23 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment. I'm seeing precommit CI failures: Failed Tests (1): Clang :: SemaCXX/constant-expression-cxx2b.cpp Comment at: clang/lib/Sema/SemaDeclCXX.cpp:1905 +if (SemaRef.LangOpts.CPlusPlus2b) { + if

[PATCH] D122249: [Clang] Add a compatibiliy warning for non-literals in constexpr.

2022-03-23 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added inline comments. Comment at: clang/lib/Sema/SemaDeclCXX.cpp:1905 +if (SemaRef.LangOpts.CPlusPlus2b) { + if (!VD->getType()->isLiteralType(SemaRef.Context)) +SemaRef.Diag(VD->getLocation(), hubert.reinterpretcast wrote:

[PATCH] D122249: [Clang] Add a compatibiliy warning for non-literals in constexpr.

2022-03-23 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 417535. cor3ntin added a comment. Formatting Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D122249/new/ https://reviews.llvm.org/D122249 Files: clang/include/clang/Basic/DiagnosticSemaKinds.td

[PATCH] D122249: [Clang] Add a compatibiliy warning for non-literals in constexpr.

2022-03-23 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 417534. cor3ntin added a comment. - Check That the type is dependant - Only emit the warning when Kind == Sema::CheckConstexprKind::Diagnose Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D122249/new/

[PATCH] D122249: [Clang] Add a compatibiliy warning for non-literals in constexpr.

2022-03-23 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments. Comment at: clang/test/SemaCXX/constant-expression-cxx2b.cpp:219 + NonLiteral n; // cxx2b-note {{non-literal type 'NonLiteral' cannot be used in a constant expression}} \ +// cxx2b-warning {{definition of a

[PATCH] D122249: [Clang] Add a compatibiliy warning for non-literals in constexpr.

2022-03-23 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments. Comment at: clang/lib/Sema/SemaDeclCXX.cpp:1905 +if (SemaRef.LangOpts.CPlusPlus2b) { + if (!VD->getType()->isLiteralType(SemaRef.Context)) +SemaRef.Diag(VD->getLocation(), This seems to

[PATCH] D122249: [Clang] Add a compatibiliy warning for non-literals in constexpr.

2022-03-22 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 417376. cor3ntin added a comment. - fix formatting - use cxx2b in the test as per aaron request. This doesn't really matter as this part of the test file is only executed in c++2b mode though. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST

[PATCH] D122249: [Clang] Add a compatibiliy warning for non-literals in constexpr.

2022-03-22 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments. Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:2725 +def warn_cxx20_compat_constexpr_var : Warning< + "definition of a %select{static variable|thread_local variable|variable of non-literal type}1 " "in a constexpr

[PATCH] D122249: [Clang] Add a compatibiliy warning for non-literals in constexpr.

2022-03-22 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin created this revision. Herald added a project: All. cor3ntin requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D122249 Files: