[PATCH] D111400: [Clang] Implement P2242R3

2022-03-17 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment. @hubert.reinterpretcast I added the tests, please let me know what you think. Thanks! Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D111400/new/ https://reviews.llvm.org/D111400

[PATCH] D111400: [Clang] Implement P2242R3

2022-03-16 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 415720. cor3ntin added a comment. Formatting Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D111400/new/ https://reviews.llvm.org/D111400 Files: clang/docs/ReleaseNotes.rst

[PATCH] D111400: [Clang] Implement P2242R3

2022-03-16 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 415719. cor3ntin added a comment. Add more tests for implicitely constexpr lambdas Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D111400/new/ https://reviews.llvm.org/D111400 Files:

[PATCH] D111400: [Clang] Implement P2242R3

2022-03-15 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments. Comment at: clang/test/SemaCXX/constant-expression-cxx2b.cpp:101 + + auto b = [](int n) constexpr { +if (!n) I think a lambda marked `constexpr` and one that isn't has fundamental differences in behaviour in

[PATCH] D111400: [Clang] Implement P2242R3

2022-03-15 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 415574. cor3ntin added a comment. Formatting Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D111400/new/ https://reviews.llvm.org/D111400 Files: clang/docs/ReleaseNotes.rst

[PATCH] D111400: [Clang] Implement P2242R3

2022-03-15 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 415573. cor3ntin added a comment. - Add tests in lambdas - Do not allow static constexpr: I can't think of a scenario in which that would be problematic *today*, but I agree it would be non-conforming and should be discussed. For example it would affect

[PATCH] D111400: [Clang] Implement P2242R3

2022-03-15 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment. In D111400#3383006 , @hubert.reinterpretcast wrote: > @aaron.ballman @cor3ntin, are we confident that testing the non-lambda cases > is sufficient to cover the lambda cases as well? I think lambdas are just odd enough

[PATCH] D111400: [Clang] Implement P2242R3

2022-03-15 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added a comment. @aaron.ballman @cor3ntin, are we confident that testing the non-lambda cases is sufficient to cover the lambda cases as well? I suggest using a pattern such as: int (*test_cxx2b_constexpr_label_in_body())() { auto qq = []() { label: return

[PATCH] D111400: [Clang] Implement P2242R3

2022-03-15 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 415464. cor3ntin added a comment. Fix test Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D111400/new/ https://reviews.llvm.org/D111400 Files: clang/docs/ReleaseNotes.rst

[PATCH] D111400: [Clang] Implement P2242R3

2022-03-15 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 415438. cor3ntin added a comment. Restore the C++14 tests Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D111400/new/ https://reviews.llvm.org/D111400 Files: clang/docs/ReleaseNotes.rst

[PATCH] D111400: [Clang] Implement P2242R3

2022-03-15 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments. Comment at: clang/lib/Sema/SemaDeclCXX.cpp:2132-2136 +for (Stmt *SubStmt : S->children()) + if (SubStmt && + !CheckConstexprFunctionStmt(SemaRef, Dcl, SubStmt, ReturnStmts, + Cxx1yLoc,

[PATCH] D111400: [Clang] Implement P2242R3

2022-03-15 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments. Comment at: clang/test/SemaCXX/constant-expression-cxx2b.cpp:60-61 + +constexpr int ke = k_evaluated(1); //expected-error {{constexpr variable 'ke' must be initialized by a constant expression}} \ +

[PATCH] D111400: [Clang] Implement P2242R3

2022-03-15 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added inline comments. Comment at: clang/lib/Sema/SemaDeclCXX.cpp:2132-2136 +for (Stmt *SubStmt : S->children()) + if (SubStmt && + !CheckConstexprFunctionStmt(SemaRef, Dcl, SubStmt, ReturnStmts, + Cxx1yLoc,

[PATCH] D111400: [Clang] Implement P2242R3

2022-03-15 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added inline comments. Comment at: clang/test/SemaCXX/constant-expression-cxx2b.cpp:60-61 + +constexpr int ke = k_evaluated(1); //expected-error {{constexpr variable 'ke' must be initialized by a constant expression}} \ +

[PATCH] D111400: [Clang] Implement P2242R3

2022-03-15 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments. Comment at: clang/lib/Sema/SemaDeclCXX.cpp:2132-2136 +for (Stmt *SubStmt : S->children()) + if (SubStmt && + !CheckConstexprFunctionStmt(SemaRef, Dcl, SubStmt, ReturnStmts, + Cxx1yLoc,

[PATCH] D111400: [Clang] Implement P2242R3

2022-03-15 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added inline comments. Comment at: clang/lib/Sema/SemaDeclCXX.cpp:2132-2136 +for (Stmt *SubStmt : S->children()) + if (SubStmt && + !CheckConstexprFunctionStmt(SemaRef, Dcl, SubStmt, ReturnStmts, + Cxx1yLoc,

[PATCH] D111400: [Clang] Implement P2242R3

2022-03-15 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 415425. cor3ntin marked 6 inline comments as done. cor3ntin added a comment. Address formatting and style issues Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D111400/new/ https://reviews.llvm.org/D111400

[PATCH] D111400: [Clang] Implement P2242R3

2022-03-15 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments. Comment at: clang/lib/AST/ExprConstant.cpp:5128-5130 + if (!CheckLocalVariableDeclaration(Info, VD)) { +return ESR_Failed; + } Comment at:

[PATCH] D111400: [Clang] Implement P2242R3

2022-03-15 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 415353. cor3ntin added a comment. Fix test messed up by automatic formatting. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D111400/new/ https://reviews.llvm.org/D111400 Files: clang/docs/ReleaseNotes.rst

[PATCH] D111400: [Clang] Implement P2242R3

2022-03-14 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 415240. cor3ntin added a comment. clamg-format Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D111400/new/ https://reviews.llvm.org/D111400 Files: clang/docs/ReleaseNotes.rst

[PATCH] D111400: [Clang] Implement P2242R3

2022-03-14 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 415041. cor3ntin marked 2 inline comments as done. cor3ntin added a comment. Address Hubert's feedback - Add a diagnostic during constant evaluation when evaluating the declaration of a variable with non-automatic storage duration - Add more tests -

[PATCH] D111400: [Clang] Implement P2242R3

2022-03-13 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments. Comment at: clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3-2b.cpp:16 +} + +constexpr int f(int x) { Add a `NonLiteral` case and a case with a labelled statement and no `goto`? Comment at:

[PATCH] D111400: [Clang] Implement P2242R3

2022-03-12 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added a comment. Noting for myself: Clang's status quo already has behaviours that are similar to P2242R3 in its C++20 mode despite those behaviours being non-conforming and contributing to binary compat breakage with GCC. This patch is not responsible for those

[PATCH] D111400: [Clang] Implement P2242R3

2022-03-12 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 414880. cor3ntin added a comment. - Rebase - Update cxx_status as we are now targeting clang 15 - Test the pre-C++2b warnings Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D111400/new/

[PATCH] D111400: [Clang] Implement P2242R3

2022-03-11 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added a comment. In D111400#3376070 , @hubert.reinterpretcast wrote: > In C++2b, the `-Wc++20-compat` warning is produced for the places where we > warn above and is not produced for the places where we don't warn above. I'm not

[PATCH] D111400: [Clang] Implement P2242R3

2022-03-11 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added a comment. @aaron.ballman, I haven't had a chance to look at the code in detail yet, but I would like to get on the same page about the error/warning behaviour. In the older modes, we stay conforming either - by producing the warning (when we know the user said

[PATCH] D111400: [Clang] Implement P2242R3

2022-03-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment. Herald added a project: All. In D111400#985 , @cor3ntin wrote: > @hubert.reinterpretcast Gentle ping in case you didn't see Aaron's message - > there isn't too much urgency though Another ping on this since a few

[PATCH] D111400: [Clang] Implement P2242R3

2022-02-20 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment. @hubert.reinterpretcast Gentle ping in case you didn't see Aaron's message - there isn't too much urgency though Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D111400/new/ https://reviews.llvm.org/D111400

[PATCH] D111400: [Clang] Implement P2242R3

2022-01-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment. In D111400#3246323 , @cor3ntin wrote: > In D111400#3243826 , @aaron.ballman > wrote: > >> In D111400#3172097 , @cor3ntin >> wrote: >> >>>

[PATCH] D111400: [Clang] Implement P2242R3

2022-01-15 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 400325. cor3ntin added a comment. run clang-format. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D111400/new/ https://reviews.llvm.org/D111400 Files: clang/docs/ReleaseNotes.rst

[PATCH] D111400: [Clang] Implement P2242R3

2022-01-15 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment. In D111400#3243826 , @aaron.ballman wrote: > In D111400#3172097 , @cor3ntin > wrote: > >> Regression compared to the status quo: >> This code no longer warns (as noted by Hubert above)

[PATCH] D111400: [Clang] Implement P2242R3

2022-01-15 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 400317. cor3ntin added a comment. Fix tests Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D111400/new/ https://reviews.llvm.org/D111400 Files: clang/docs/ReleaseNotes.rst

[PATCH] D111400: [Clang] Implement P2242R3

2022-01-14 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment. In D111400#3172097 , @cor3ntin wrote: > Regression compared to the status quo: > This code no longer warns (as noted by Hubert above) > > auto f = [](bool b) { > if (b) return 42; > static int x = 0; > return

[PATCH] D111400: [Clang] Implement P2242R3

2021-12-05 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment. Regression compared to the status quo: This code no longer warns (as noted by Hubert above) auto f = [](bool b) { if (b) return 42; static int x = 0; return x; }; constexpr int x = f(true); const int *p = GCC doesn't warn and... if we wanted to

[PATCH] D111400: [Clang] Implement P2242R3

2021-12-05 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 391906. cor3ntin added a comment. Treat non-literals in constexpr as an error before C++23 Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D111400/new/ https://reviews.llvm.org/D111400 Files:

[PATCH] D111400: [Clang] Implement P2242R3

2021-12-05 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment. In D111400#3165668 , @hubert.reinterpretcast wrote: > In D111400#3164301 , @cor3ntin > wrote: > >> If the issue is regarding the support and extension warning in C++20 and >> older

[PATCH] D111400: [Clang] Implement P2242R3

2021-12-01 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added a comment. In D111400#3164301 , @cor3ntin wrote: > If the issue is regarding the support and extension warning in C++20 and > older modes, it's something I can address by conserving the status quo in > older versions. I

[PATCH] D111400: [Clang] Implement P2242R3

2021-12-01 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment. In D111400#3164249 , @aaron.ballman wrote: > In D111400#3088321 , @aaron.ballman > wrote: > >> In D111400#3088133 , >>

[PATCH] D111400: [Clang] Implement P2242R3

2021-12-01 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment. In D111400#3088321 , @aaron.ballman wrote: > In D111400#3088133 , > @hubert.reinterpretcast wrote: > >> In D111400#3087877 , >>

[PATCH] D111400: [Clang] Implement P2242R3

2021-10-27 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added a comment. Lambda capture semantics mean that extensions or inconsistencies in constexpr evaluation result in binary-compatibility issues. struct NonLit { NonLit(); }; template constexpr int foo() { return 42; T t; } extern int g(void *);

[PATCH] D111400: [Clang] Implement P2242R3

2021-10-27 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added a comment. A different "ouch" (and, yes, this is a regression from this patch): auto f = [](bool b) { if (b) return 42; static int x = 0; return x; }; constexpr int x = f(true); const int *p = Generates no diagnostics with this patch even with

[PATCH] D111400: [Clang] Implement P2242R3

2021-10-26 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment. In D111400#3088133 , @hubert.reinterpretcast wrote: > In D111400#3087877 , @aaron.ballman > wrote: > >> So your concern is that allowing this patch to be used as an extension in

[PATCH] D111400: [Clang] Implement P2242R3

2021-10-26 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added a comment. In D111400#3087877 , @aaron.ballman wrote: > So your concern is that allowing this patch to be used as an extension in > older language modes may change the behavior of existing code? Or is your > concern more

[PATCH] D111400: [Clang] Implement P2242R3

2021-10-26 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a reviewer: rsmith. aaron.ballman added a comment. In D111400#3052314 , @hubert.reinterpretcast wrote: > I am concerned that the general direction of this patch (to allow the > previously ill-formed constexpr functions as an

[PATCH] D111400: [Clang] Implement P2242R3

2021-10-08 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added a comment. I am concerned that the general direction of this patch (to allow the previously ill-formed constexpr functions as an extension under older language levels) is based upon bugs/divergences-from-orthodoxy in Clang's implementation of C++20 (noting that the

[PATCH] D111400: [Clang] Implement P2242R3

2021-10-08 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 378173. cor3ntin added a comment. Add missing test file Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D111400/new/ https://reviews.llvm.org/D111400 Files: clang/docs/ReleaseNotes.rst

[PATCH] D111400: [Clang] Implement P2242R3

2021-10-08 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 378172. cor3ntin added a comment. Fix diagnostics formatting Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D111400/new/ https://reviews.llvm.org/D111400 Files: clang/docs/ReleaseNotes.rst

[PATCH] D111400: [Clang] Implement P2242R3

2021-10-08 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin created this revision. cor3ntin requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits. Allow goto, label statements as well as static, thread_local and non-literal variables in constexpr functions. The proposal is implemented as a