[clang] [clang] fix constexpr-unknown handling of self-references. (PR #132990)

2025-05-19 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic closed https://github.com/llvm/llvm-project/pull/132990 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] fix constexpr-unknown handling of self-references. (PR #132990)

2025-05-16 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic updated https://github.com/llvm/llvm-project/pull/132990 Rate limit ยท GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,

[clang] [clang] fix constexpr-unknown handling of self-references. (PR #132990)

2025-05-16 Thread via cfe-commits
https://github.com/cor3ntin edited https://github.com/llvm/llvm-project/pull/132990 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] fix constexpr-unknown handling of self-references. (PR #132990)

2025-05-16 Thread via cfe-commits
@@ -3629,17 +3644,17 @@ static bool evaluateVarDeclInit(EvalInfo &Info, const Expr *E, Result = VD->getEvaluatedValue(); - // C++23 [expr.const]p8 - // ... For such an object that is not usable in constant expressions, the - // dynamic type of the object is constexpr-un

[clang] [clang] fix constexpr-unknown handling of self-references. (PR #132990)

2025-05-16 Thread via cfe-commits
https://github.com/cor3ntin approved this pull request. LGTM modulo nit https://github.com/llvm/llvm-project/pull/132990 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] fix constexpr-unknown handling of self-references. (PR #132990)

2025-04-28 Thread Brian Bi via cfe-commits
t3nsor wrote: No opinions about the code, but on the reflector we did agree that rejecting those initialization cases was the right thing to do. https://github.com/llvm/llvm-project/pull/132990 ___ cfe-commits mailing list cfe-commits@lists.llvm.org h

[clang] [clang] fix constexpr-unknown handling of self-references. (PR #132990)

2025-03-28 Thread Shafik Yaghmour via cfe-commits
@@ -3629,17 +3644,17 @@ static bool evaluateVarDeclInit(EvalInfo &Info, const Expr *E, Result = VD->getEvaluatedValue(); - // C++23 [expr.const]p8 - // ... For such an object that is not usable in constant expressions, the - // dynamic type of the object is constexpr-un

[clang] [clang] fix constexpr-unknown handling of self-references. (PR #132990)

2025-03-28 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic updated https://github.com/llvm/llvm-project/pull/132990 >From 2873bb1aee5470ecd7fa66c1f255bfe8b26dbc68 Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Mon, 17 Mar 2025 11:20:21 -0700 Subject: [PATCH 1/2] [clang] fix constexpr-unknown handling of self-referen

[clang] [clang] fix constexpr-unknown handling of self-references. (PR #132990)

2025-03-28 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic commented: Addressed review comments. We now reject g3() and g5(), the cases that involved using a local variable in a constexpr function in its own initializer. https://github.com/llvm/llvm-project/pull/132990 ___ cf

[clang] [clang] fix constexpr-unknown handling of self-references. (PR #132990)

2025-03-28 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic updated https://github.com/llvm/llvm-project/pull/132990 >From 2873bb1aee5470ecd7fa66c1f255bfe8b26dbc68 Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Mon, 17 Mar 2025 11:20:21 -0700 Subject: [PATCH 1/3] [clang] fix constexpr-unknown handling of self-referen

[clang] [clang] fix constexpr-unknown handling of self-references. (PR #132990)

2025-03-28 Thread Shafik Yaghmour via cfe-commits
@@ -177,3 +177,50 @@ namespace extern_reference_used_as_unknown { int y; constinit int& g = (x,y); // expected-warning {{left operand of comma operator has no effect}} } + +namespace uninit_reference_used { + int y; + constexpr int &r = r; // expected-error {{must be ini

[clang] [clang] fix constexpr-unknown handling of self-references. (PR #132990)

2025-03-28 Thread via cfe-commits
@@ -177,3 +177,50 @@ namespace extern_reference_used_as_unknown { int y; constinit int& g = (x,y); // expected-warning {{left operand of comma operator has no effect}} } + +namespace uninit_reference_used { + int y; + constexpr int &r = r; // expected-error {{must be ini

[clang] [clang] fix constexpr-unknown handling of self-references. (PR #132990)

2025-03-26 Thread via cfe-commits
@@ -177,3 +177,50 @@ namespace extern_reference_used_as_unknown { int y; constinit int& g = (x,y); // expected-warning {{left operand of comma operator has no effect}} } + +namespace uninit_reference_used { + int y; + constexpr int &r = r; // expected-error {{must be ini

[clang] [clang] fix constexpr-unknown handling of self-references. (PR #132990)

2025-03-26 Thread via cfe-commits
cor3ntin wrote: > > Do you intend to backport this change to 20? > > The weird behavior only shows up if you refer to a reference variable inside > its own initializer, as far as I can tell. Maybe not worth backporting, even > if it is a regression, because people shouldn't be writing code lik

[clang] [clang] fix constexpr-unknown handling of self-references. (PR #132990)

2025-03-26 Thread Brian Bi via cfe-commits
@@ -177,3 +177,50 @@ namespace extern_reference_used_as_unknown { int y; constinit int& g = (x,y); // expected-warning {{left operand of comma operator has no effect}} } + +namespace uninit_reference_used { + int y; + constexpr int &r = r; // expected-error {{must be ini

[clang] [clang] fix constexpr-unknown handling of self-references. (PR #132990)

2025-03-26 Thread Eli Friedman via cfe-commits
@@ -3629,17 +3644,17 @@ static bool evaluateVarDeclInit(EvalInfo &Info, const Expr *E, Result = VD->getEvaluatedValue(); - // C++23 [expr.const]p8 - // ... For such an object that is not usable in constant expressions, the - // dynamic type of the object is constexpr-un

[clang] [clang] fix constexpr-unknown handling of self-references. (PR #132990)

2025-03-26 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: > Do you intend to backport this change to 20? The weird behavior only shows up if you refer to a reference variable inside its own initializer, as far as I can tell. Maybe not worth backporting, even if it is a regression, because people shouldn't be writing code like th

[clang] [clang] fix constexpr-unknown handling of self-references. (PR #132990)

2025-03-26 Thread Eli Friedman via cfe-commits
@@ -177,3 +177,50 @@ namespace extern_reference_used_as_unknown { int y; constinit int& g = (x,y); // expected-warning {{left operand of comma operator has no effect}} } + +namespace uninit_reference_used { + int y; + constexpr int &r = r; // expected-error {{must be ini

[clang] [clang] fix constexpr-unknown handling of self-references. (PR #132990)

2025-03-26 Thread via cfe-commits
https://github.com/cor3ntin edited https://github.com/llvm/llvm-project/pull/132990 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] fix constexpr-unknown handling of self-references. (PR #132990)

2025-03-26 Thread via cfe-commits
@@ -3485,11 +3485,27 @@ static bool evaluateVarDeclInit(EvalInfo &Info, const Expr *E, APValue::LValueBase Base(VD, Frame ? Frame->Index : 0, Version); + auto CheckUninitReference = [&] { +if (!Result->hasValue() && VD->getType()->isReferenceType()) { + // We can

[clang] [clang] fix constexpr-unknown handling of self-references. (PR #132990)

2025-03-26 Thread via cfe-commits
@@ -177,3 +177,50 @@ namespace extern_reference_used_as_unknown { int y; constinit int& g = (x,y); // expected-warning {{left operand of comma operator has no effect}} } + +namespace uninit_reference_used { + int y; + constexpr int &r = r; // expected-error {{must be ini

[clang] [clang] fix constexpr-unknown handling of self-references. (PR #132990)

2025-03-26 Thread via cfe-commits
@@ -3629,17 +3644,17 @@ static bool evaluateVarDeclInit(EvalInfo &Info, const Expr *E, Result = VD->getEvaluatedValue(); - // C++23 [expr.const]p8 - // ... For such an object that is not usable in constant expressions, the - // dynamic type of the object is constexpr-un

[clang] [clang] fix constexpr-unknown handling of self-references. (PR #132990)

2025-03-26 Thread via cfe-commits
@@ -3485,11 +3485,27 @@ static bool evaluateVarDeclInit(EvalInfo &Info, const Expr *E, APValue::LValueBase Base(VD, Frame ? Frame->Index : 0, Version); + auto CheckUninitReference = [&] { +if (!Result->hasValue() && VD->getType()->isReferenceType()) { + // We can

[clang] [clang] fix constexpr-unknown handling of self-references. (PR #132990)

2025-03-26 Thread via cfe-commits
@@ -3629,17 +3644,17 @@ static bool evaluateVarDeclInit(EvalInfo &Info, const Expr *E, Result = VD->getEvaluatedValue(); - // C++23 [expr.const]p8 - // ... For such an object that is not usable in constant expressions, the - // dynamic type of the object is constexpr-un

[clang] [clang] fix constexpr-unknown handling of self-references. (PR #132990)

2025-03-26 Thread via cfe-commits
https://github.com/cor3ntin commented: Thanks. I think the direction makes sense Do you intend to backport this change to 20? https://github.com/llvm/llvm-project/pull/132990 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.

[clang] [clang] fix constexpr-unknown handling of self-references. (PR #132990)

2025-03-25 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic created https://github.com/llvm/llvm-project/pull/132990 Usually, in constant evaluation, references which are local to the evaluation have to be initialized before they're accessed. However, there's one funny special case: the initializer of a reference can r

[clang] [clang] fix constexpr-unknown handling of self-references. (PR #132990)

2025-03-25 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic updated https://github.com/llvm/llvm-project/pull/132990 >From 2873bb1aee5470ecd7fa66c1f255bfe8b26dbc68 Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Mon, 17 Mar 2025 11:20:21 -0700 Subject: [PATCH] [clang] fix constexpr-unknown handling of self-references.

[clang] [clang] fix constexpr-unknown handling of self-references. (PR #132990)

2025-03-25 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 cc86d7cb191a64489e837c68f299abb930f5c6cb f5195b8d3d7ac00e8a0a54c10be485d69a576ba5 --e

[clang] [clang] fix constexpr-unknown handling of self-references. (PR #132990)

2025-03-25 Thread via cfe-commits
llvmbot wrote: @llvm/pr-subscribers-clang Author: Eli Friedman (efriedma-quic) Changes Usually, in constant evaluation, references which are local to the evaluation have to be initialized before they're accessed. However, there's one funny special case: the initializer of a reference ca