[clang] [Clang] Fix P2564 handling of variable initializers (PR #89565)

2024-05-18 Thread Daniel M. Katz via cfe-commits
katzdm wrote: > @katzdm Does it make sense to file an issue so we don't forget to bring the > warning back? Yep, for sure - I've opened #92656. https://github.com/llvm/llvm-project/pull/89565 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

[clang] [Clang] Fix P2564 handling of variable initializers (PR #89565)

2024-05-16 Thread Daniel M. Katz via cfe-commits
katzdm wrote: @Fznamznon Hmm...my suggested change does seem to break some tests :( But to circle back to your original question, I think it's not totally unexpected - a broader class of variable initializers are now (correctly afaict) evaluated as constant expressions, which could make some

[clang] [Clang] Fix P2564 handling of variable initializers (PR #89565)

2024-05-16 Thread Daniel M. Katz via cfe-commits
katzdm wrote: > @katzdm It seems after this a `warn_impcast_integer_precision_constant` > warning went missing: > > https://godbolt.org/z/ndsPb44b4 > > Is that expected? We changed [this

[clang] [Clang] Fix P2564 handling of variable initializers (PR #89565)

2024-05-08 Thread Daniel M. Katz via cfe-commits
https://github.com/katzdm updated https://github.com/llvm/llvm-project/pull/89565 >From 218ffb6d5a03c96d46bfecdb4490277809f5b62e Mon Sep 17 00:00:00 2001 From: Dan Katz Date: Tue, 16 Apr 2024 17:14:50 -0400 Subject: [PATCH 1/8] Fix bug with constexpr initialization. ---

[clang] [Clang] Fix P2564 handling of variable initializers (PR #89565)

2024-05-08 Thread Daniel M. Katz via cfe-commits
https://github.com/katzdm updated https://github.com/llvm/llvm-project/pull/89565 >From 218ffb6d5a03c96d46bfecdb4490277809f5b62e Mon Sep 17 00:00:00 2001 From: Dan Katz Date: Tue, 16 Apr 2024 17:14:50 -0400 Subject: [PATCH 1/8] Fix bug with constexpr initialization. ---

[clang] Fix P2564 handling of variable initializers (PR #89565)

2024-05-07 Thread Daniel M. Katz via cfe-commits
https://github.com/katzdm edited https://github.com/llvm/llvm-project/pull/89565 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Don't wrap immediate invocations in ConstantExprs within constexpr initializers (PR #89565)

2024-05-06 Thread Daniel M. Katz via cfe-commits
katzdm wrote:  Friendly ping - No worries if more time is needed to consider the impact of this one, but wanted to check if any more changes are needed at this time. https://github.com/llvm/llvm-project/pull/89565 ___ cfe-commits mailing list

[clang] Don't wrap immediate invocations in ConstantExprs within constexpr initializers (PR #89565)

2024-04-29 Thread Daniel M. Katz via cfe-commits
@@ -16548,11 +16548,10 @@ static void CheckImplicitConversion(Sema , Expr *E, QualType T, std::string PrettySourceValue = toString(Value, 10); std::string PrettyTargetValue = PrettyPrintInRange(Value, TargetRange); -S.DiagRuntimeBehavior( -

[clang] Don't wrap immediate invocations in ConstantExprs within constexpr initializers (PR #89565)

2024-04-29 Thread Daniel M. Katz via cfe-commits
@@ -18573,25 +18562,35 @@ void Sema::ActOnCXXEnterDeclInitializer(Scope *S, Decl *D) { if (S && D->isOutOfLine()) EnterDeclaratorContext(S, D->getDeclContext()); - // If we are parsing the initializer for a static data member, push a - // new expression evaluation

[clang] Don't wrap immediate invocations in ConstantExprs within constexpr initializers (PR #89565)

2024-04-29 Thread Daniel M. Katz via cfe-commits
https://github.com/katzdm updated https://github.com/llvm/llvm-project/pull/89565 >From 218ffb6d5a03c96d46bfecdb4490277809f5b62e Mon Sep 17 00:00:00 2001 From: Dan Katz Date: Tue, 16 Apr 2024 17:14:50 -0400 Subject: [PATCH 1/8] Fix bug with constexpr initialization. ---

[clang] Don't wrap immediate invocations in ConstantExprs within constexpr initializers (PR #89565)

2024-04-29 Thread Daniel M. Katz via cfe-commits
@@ -16548,11 +16548,10 @@ static void CheckImplicitConversion(Sema , Expr *E, QualType T, std::string PrettySourceValue = toString(Value, 10); std::string PrettyTargetValue = PrettyPrintInRange(Value, TargetRange); -S.DiagRuntimeBehavior( -

[clang] Don't wrap immediate invocations in ConstantExprs within constexpr initializers (PR #89565)

2024-04-29 Thread Daniel M. Katz via cfe-commits
@@ -18573,25 +18562,35 @@ void Sema::ActOnCXXEnterDeclInitializer(Scope *S, Decl *D) { if (S && D->isOutOfLine()) EnterDeclaratorContext(S, D->getDeclContext()); - // If we are parsing the initializer for a static data member, push a - // new expression evaluation

[clang] Don't wrap immediate invocations in ConstantExprs within constexpr initializers (PR #89565)

2024-04-29 Thread Daniel M. Katz via cfe-commits
@@ -18562,9 +18553,7 @@ static bool isNonlocalVariable(const Decl *D) { /// class X. If the declaration had a scope specifier, a scope will have /// been created and passed in for this purpose. Otherwise, S will be null. void Sema::ActOnCXXEnterDeclInitializer(Scope *S, Decl

[clang] Don't wrap immediate invocations in ConstantExprs within constexpr initializers (PR #89565)

2024-04-26 Thread Daniel M. Katz via cfe-commits
https://github.com/katzdm updated https://github.com/llvm/llvm-project/pull/89565 >From 218ffb6d5a03c96d46bfecdb4490277809f5b62e Mon Sep 17 00:00:00 2001 From: Dan Katz Date: Tue, 16 Apr 2024 17:14:50 -0400 Subject: [PATCH 1/7] Fix bug with constexpr initialization. ---

[clang] Don't wrap immediate invocations in ConstantExprs within constexpr initializers (PR #89565)

2024-04-26 Thread Daniel M. Katz via cfe-commits
https://github.com/katzdm edited https://github.com/llvm/llvm-project/pull/89565 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Don't wrap immediate invocations in ConstantExprs within constexpr initializers (PR #89565)

2024-04-26 Thread Daniel M. Katz via cfe-commits
https://github.com/katzdm updated https://github.com/llvm/llvm-project/pull/89565 >From 218ffb6d5a03c96d46bfecdb4490277809f5b62e Mon Sep 17 00:00:00 2001 From: Dan Katz Date: Tue, 16 Apr 2024 17:14:50 -0400 Subject: [PATCH 1/7] Fix bug with constexpr initialization. ---

[clang] Don't wrap immediate invocations in ConstantExprs within constexpr initializers (PR #89565)

2024-04-26 Thread Daniel M. Katz via cfe-commits
@@ -1032,17 +1043,15 @@ int f() { namespace GH57682 { void test() { - constexpr auto l1 = []() consteval { // expected-error {{cannot take address of consteval call operator of '(lambda at}} \ - // expected-note 2{{declared here}} +

[clang] Don't wrap immediate invocations in ConstantExprs within constexpr initializers (PR #89565)

2024-04-26 Thread Daniel M. Katz via cfe-commits
@@ -244,8 +244,8 @@ namespace UndefinedBehavior { constexpr int n13 = n5 + n5; // expected-error {{constant expression}} expected-note {{value -4294967296 is outside the range of }} constexpr int n14 = n3 - n5; // expected-error {{constant expression}} expected-note

[clang] Don't wrap immediate invocations in ConstantExprs within constexpr initializers (PR #89565)

2024-04-26 Thread Daniel M. Katz via cfe-commits
@@ -2554,16 +2554,27 @@ Decl *Parser::ParseDeclarationAfterDeclarator( return ParseDeclarationAfterDeclaratorAndAttributes(D, TemplateInfo); } +static bool isConstexprVariable(const Decl *D) { + if (const VarDecl *Var = dyn_cast_if_present(D)) +return

[clang] Don't wrap immediate invocations in ConstantExprs within constexpr initializers (PR #89565)

2024-04-26 Thread Daniel M. Katz via cfe-commits
katzdm wrote: This ended up being a lot more subtle than I expected. My latest push proposes a different solution; @cor3ntin and @efriedma-quic - please let me know your thoughts. This PR turns out to be a bug fix on the implementation of [P2564R3](https://wg21.link/p2564r3); as such, it

[clang] Don't wrap immediate invocations in ConstantExprs within constexpr initializers (PR #89565)

2024-04-26 Thread Daniel M. Katz via cfe-commits
https://github.com/katzdm updated https://github.com/llvm/llvm-project/pull/89565 >From 218ffb6d5a03c96d46bfecdb4490277809f5b62e Mon Sep 17 00:00:00 2001 From: Dan Katz Date: Tue, 16 Apr 2024 17:14:50 -0400 Subject: [PATCH 1/6] Fix bug with constexpr initialization. ---

[clang] Don't wrap immediate invocations in ConstantExprs within constexpr initializers (PR #89565)

2024-04-23 Thread Daniel M. Katz via cfe-commits
@@ -2554,16 +2554,27 @@ Decl *Parser::ParseDeclarationAfterDeclarator( return ParseDeclarationAfterDeclaratorAndAttributes(D, TemplateInfo); } +static bool isConstexprVariable(const Decl *D) { + if (const VarDecl *Var = dyn_cast_if_present(D)) +return

[clang] Don't wrap immediate invocations in ConstantExprs within constexpr initializers (PR #89565)

2024-04-23 Thread Daniel M. Katz via cfe-commits
@@ -2554,16 +2554,27 @@ Decl *Parser::ParseDeclarationAfterDeclarator( return ParseDeclarationAfterDeclaratorAndAttributes(D, TemplateInfo); } +static bool isConstexprVariable(const Decl *D) { + if (const VarDecl *Var = dyn_cast_if_present(D)) +return

[clang] Don't wrap immediate invocations in ConstantExprs within constexpr initializers (PR #89565)

2024-04-23 Thread Daniel M. Katz via cfe-commits
@@ -244,8 +244,8 @@ namespace UndefinedBehavior { constexpr int n13 = n5 + n5; // expected-error {{constant expression}} expected-note {{value -4294967296 is outside the range of }} constexpr int n14 = n3 - n5; // expected-error {{constant expression}} expected-note

[clang] Don't wrap immediate invocations in ConstantExprs within constexpr initializers (PR #89565)

2024-04-23 Thread Daniel M. Katz via cfe-commits
@@ -244,8 +244,8 @@ namespace UndefinedBehavior { constexpr int n13 = n5 + n5; // expected-error {{constant expression}} expected-note {{value -4294967296 is outside the range of }} constexpr int n14 = n3 - n5; // expected-error {{constant expression}} expected-note

[clang] Push immediate function context while transforming lambdas in templates. (PR #89702)

2024-04-23 Thread Daniel M. Katz via cfe-commits
katzdm wrote: > LGTM, thanks! Will you need me to merge the change for you? @cor3ntin That would be great, thanks! https://github.com/llvm/llvm-project/pull/89702 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

[clang] Push immediate function context while transforming lambdas in templates. (PR #89702)

2024-04-22 Thread Daniel M. Katz via cfe-commits
https://github.com/katzdm updated https://github.com/llvm/llvm-project/pull/89702 >From ba1c87956f74248467d2f85c20c2f450eef953bd Mon Sep 17 00:00:00 2001 From: Dan Katz Date: Mon, 22 Apr 2024 22:39:06 -0400 Subject: [PATCH] Push immediate function context while transforming lambdas in

[clang] Push immediate function context while transforming lambdas in templates. (PR #89702)

2024-04-22 Thread Daniel M. Katz via cfe-commits
https://github.com/katzdm created https://github.com/llvm/llvm-project/pull/89702 The following program is [accepted](https://godbolt.org/z/oEc34Trh4) by Clang, EDG, and MSVC, but rejected by Clang: ```cpp #include consteval auto fn() { return std::vector {1,2,3}; } template void fn2() {

[clang] Don't wrap immediate invocations in ConstantExprs within constexpr initializers (PR #89565)

2024-04-22 Thread Daniel M. Katz via cfe-commits
@@ -2554,16 +2554,26 @@ Decl *Parser::ParseDeclarationAfterDeclarator( return ParseDeclarationAfterDeclaratorAndAttributes(D, TemplateInfo); } +static bool isConstexprVariable(const Decl *D) { + if (const VarDecl *Var = dyn_cast_or_null(D)) katzdm wrote:

[clang] Don't wrap immediate invocations in ConstantExprs within constexpr initializers (PR #89565)

2024-04-22 Thread Daniel M. Katz via cfe-commits
@@ -1032,17 +1043,15 @@ int f() { namespace GH57682 { void test() { - constexpr auto l1 = []() consteval { // expected-error {{cannot take address of consteval call operator of '(lambda at}} \ - // expected-note 2{{declared here}} +

[clang] Don't wrap immediate invocations in ConstantExprs within constexpr initializers (PR #89565)

2024-04-22 Thread Daniel M. Katz via cfe-commits
@@ -2554,16 +2554,26 @@ Decl *Parser::ParseDeclarationAfterDeclarator( return ParseDeclarationAfterDeclaratorAndAttributes(D, TemplateInfo); } +static bool isConstexprVariable(const Decl *D) { + if (const VarDecl *Var = dyn_cast_or_null(D)) katzdm wrote:

[clang] Don't wrap immediate invocations in ConstantExprs within constexpr initializers (PR #89565)

2024-04-22 Thread Daniel M. Katz via cfe-commits
https://github.com/katzdm commented: @cor3ntin Thanks for your review; this is ready for another look. Note that the use of a full `ExpressionEvaluationContext` caused a handful of other tests to start failing - in particular, ones that previously expected warnings related to changes of value

[clang] Don't wrap immediate invocations in ConstantExprs within constexpr initializers (PR #89565)

2024-04-22 Thread Daniel M. Katz via cfe-commits
https://github.com/katzdm edited https://github.com/llvm/llvm-project/pull/89565 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Don't wrap immediate invocations in ConstantExprs within constexpr initializers (PR #89565)

2024-04-22 Thread Daniel M. Katz via cfe-commits
https://github.com/katzdm updated https://github.com/llvm/llvm-project/pull/89565 >From a3f8a8648e2002273d47d7886b29fb02c728b5b7 Mon Sep 17 00:00:00 2001 From: Dan Katz Date: Tue, 16 Apr 2024 17:14:50 -0400 Subject: [PATCH 1/5] Fix bug with constexpr initialization. ---

[clang] Don't wrap immediate invocations in ConstantExprs within constexpr initializers (PR #89565)

2024-04-22 Thread Daniel M. Katz via cfe-commits
https://github.com/katzdm updated https://github.com/llvm/llvm-project/pull/89565 >From a3f8a8648e2002273d47d7886b29fb02c728b5b7 Mon Sep 17 00:00:00 2001 From: Dan Katz Date: Tue, 16 Apr 2024 17:14:50 -0400 Subject: [PATCH 1/2] Fix bug with constexpr initialization. ---

[clang] Don't wrap immediate invocations in ConstantExprs within constexpr initializers (PR #89565)

2024-04-22 Thread Daniel M. Katz via cfe-commits
katzdm wrote: > I think the change makes sense. Can you add a release note? Appreciate the reminder! https://github.com/llvm/llvm-project/pull/89565 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

[clang] Don't wrap immediate invocations in ConstantExprs within constexpr initializers (PR #89565)

2024-04-21 Thread Daniel M. Katz via cfe-commits
https://github.com/katzdm created https://github.com/llvm/llvm-project/pull/89565 The following program produces a diagnostic in Clang and EDG, but compiles correctly in GCC and MSVC: ```cpp #include consteval std::vector fn() { return {1,2,3}; } constexpr int a = fn()[1]; ``` Clang's

[clang] Raise an error on namespace aliases with qualified names. (PR #86122)

2024-03-21 Thread Daniel M. Katz via cfe-commits
katzdm wrote: > You can ignore the merge conflicts in the release notes; it’s better to let > whoever ends up merging this (probably me) take care of that when it comes to > the release notes (because they get updated constantly). Ah, missed this - already fixed it. Will ignore if it happens

[clang] [llvm] Raise an error on namespace aliases with qualified names. (PR #86122)

2024-03-21 Thread Daniel M. Katz via cfe-commits
@@ -33,6 +33,7 @@ def get_num_tests(self, path, litConfig, localConfig): [path, "--gtest_list_tests", "--gtest_filter=-*DISABLED_*"] ) try: +localConfig.environment['DYLD_LIBRARY_PATH'] = '' katzdm wrote: I did not.

[clang] [llvm] Raise an error on namespace aliases with qualified names. (PR #86122)

2024-03-21 Thread Daniel M. Katz via cfe-commits
https://github.com/katzdm updated https://github.com/llvm/llvm-project/pull/86122 >From 319b7d99b4010514a1680ffd99fb0586b5e7221d Mon Sep 17 00:00:00 2001 From: Dan Katz Date: Thu, 21 Mar 2024 09:47:04 -0400 Subject: [PATCH 1/4] Raise an error on namespace aliases with qualified names. Current

[clang] Raise an error on namespace aliases with qualified names. (PR #86122)

2024-03-21 Thread Daniel M. Katz via cfe-commits
@@ -33,6 +33,7 @@ def get_num_tests(self, path, litConfig, localConfig): [path, "--gtest_list_tests", "--gtest_filter=-*DISABLED_*"] ) try: +localConfig.environment['DYLD_LIBRARY_PATH'] = '' katzdm wrote: Done, thanks

[clang] Raise an error on namespace aliases with qualified names. (PR #86122)

2024-03-21 Thread Daniel M. Katz via cfe-commits
https://github.com/katzdm updated https://github.com/llvm/llvm-project/pull/86122 >From 1998809477ce9ef03516278e1f0e9084426ea7f2 Mon Sep 17 00:00:00 2001 From: Dan Katz Date: Thu, 21 Mar 2024 09:47:04 -0400 Subject: [PATCH 1/4] Raise an error on namespace aliases with qualified names. Current

[clang] Raise an error on namespace aliases with qualified names. (PR #86122)

2024-03-21 Thread Daniel M. Katz via cfe-commits
@@ -394,6 +394,8 @@ Bug Fixes to C++ Support expression references to an entity declared outside of the lambda. (#GH64808) - Clang's __builtin_bit_cast will now produce a constant value for records with empty bases. See: (#GH82383) +- Fix an issue where a namespace alias

[clang] Raise an error on namespace aliases with qualified names. (PR #86122)

2024-03-21 Thread Daniel M. Katz via cfe-commits
https://github.com/katzdm updated https://github.com/llvm/llvm-project/pull/86122 >From 319b7d99b4010514a1680ffd99fb0586b5e7221d Mon Sep 17 00:00:00 2001 From: Dan Katz Date: Thu, 21 Mar 2024 09:47:04 -0400 Subject: [PATCH 1/3] Raise an error on namespace aliases with qualified names. Current

[clang] Raise an error on namespace aliases with qualified names. (PR #86122)

2024-03-21 Thread Daniel M. Katz via cfe-commits
https://github.com/katzdm updated https://github.com/llvm/llvm-project/pull/86122 >From 319b7d99b4010514a1680ffd99fb0586b5e7221d Mon Sep 17 00:00:00 2001 From: Dan Katz Date: Thu, 21 Mar 2024 09:47:04 -0400 Subject: [PATCH 1/2] Raise an error on namespace aliases with qualified names. Current

[clang] Raise an error on namespace aliases with qualified names. (PR #86122)

2024-03-21 Thread Daniel M. Katz via cfe-commits
katzdm wrote: @Sirraide Thanks for the quick review! I've applied your feedback. Here is an example error message with the patch applied: ``` test.cpp:4:20: error: namespace alias must be a single identifier 4 | namespace alias::extra::qualifiers = ::myns; |

[clang] Raise an error on namespace aliases with qualified names. (PR #86122)

2024-03-21 Thread Daniel M. Katz via cfe-commits
@@ -268,6 +268,8 @@ def err_expected_semi_after_namespace_name : Error< "expected ';' after namespace name">; def err_unexpected_namespace_attributes_alias : Error< "attributes cannot be specified on namespace alias">; +def err_unexpected_qualified_namespace_alias : Error<

[clang] Raise an error on namespace aliases with qualified names. (PR #86122)

2024-03-21 Thread Daniel M. Katz via cfe-commits
https://github.com/katzdm created https://github.com/llvm/llvm-project/pull/86122 Clang's current behavior is to ignore the trailing qualifiers, but the [grammar](https://eel.is/c++draft/namespace.alias#nt:namespace-alias-definition) for `namespace-alias-definition` requires an `identifier`