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

2024-05-06 Thread Vlad Serebrennikov via cfe-commits
https://github.com/Endilll commented: `Sema.h` changes look good. 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 via cfe-commits
https://github.com/cor3ntin approved this pull request. LGTM too 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 Erich Keane via cfe-commits
https://github.com/erichkeane approved this pull request. This seems reasonable to me, I think @cor3ntin should also approve before committing though. 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-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 via cfe-commits
https://github.com/cor3ntin 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-29 Thread 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
@@ -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 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 Erich Keane 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 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-29 Thread 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-29 Thread 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-29 Thread 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 via cfe-commits
@@ -2559,25 +2559,30 @@ Decl *Parser::ParseDeclarationAfterDeclaratorAndAttributes( Parser Declarator Decl *ThisDecl; +bool Entered; InitializerScopeRAII(Parser , Declarator , Decl *ThisDecl) -: P(P), D(D), ThisDecl(ThisDecl) { +:

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

2024-04-29 Thread 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 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-26 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: The approach makes sense. I'll defer to someone who's more familiar with this code for the full review. 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-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 via cfe-commits
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff 6904e0e8852a587b49a673055997e88855f219ea ec17c7668650add013f321453007191740e144e6 --

[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 Eli Friedman 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 Eli Friedman 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] Don't wrap immediate invocations in ConstantExprs within constexpr initializers (PR #89565)

2024-04-23 Thread Erich Keane via cfe-commits
https://github.com/erichkeane commented: I don't have a great idea on this one, but losing the diagnostics seems incorrect. I think the whole initializer should probably be treated in 1 shot as a constant expr (so move the ConstantExpr to the top (above the `ImplicitCastExpr` in your

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

2024-04-23 Thread Erich Keane via cfe-commits
@@ -9,8 +9,7 @@ using MaxBitInt = _BitInt(128); constexpr _BitInt(2) A = 0; constexpr _BitInt(2) B = A + 1; -constexpr _BitInt(2) C = B + 1; // expected-warning {{from 2 to -2}} \ -// ref-warning {{from 2 to -2}} +constexpr _BitInt(2) C = B +

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

2024-04-23 Thread Erich Keane via cfe-commits
https://github.com/erichkeane 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-23 Thread Erich Keane 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-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-22 Thread 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 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)) cor3ntin wrote:

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

2024-04-22 Thread 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)) +return Var->isConstexpr();

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

2024-04-22 Thread via cfe-commits
cor3ntin wrote: I think the change makes sense. Can you add a release note? 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-21 Thread via cfe-commits
llvmbot wrote: @llvm/pr-subscribers-clang Author: Daniel M. Katz (katzdm) Changes The following program produces a diagnostic in Clang and EDG, but compiles correctly in GCC and MSVC: ```cpp #include vector consteval std::vectorint fn() { return {1,2,3}; } constexpr int a = fn()[1]; ```

[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