-
Notifications
You must be signed in to change notification settings - Fork 13.3k
[clang] Allow constexpr-unknown values pre C++23 #129646
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Let's check the CI.
@llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) ChangesLet's check the CI. Full diff: https://github.com/llvm/llvm-project/pull/129646.diff 1 Files Affected:
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 6ccb6e23f8d2f..9ea42b308f42c 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -3470,8 +3470,7 @@ static bool evaluateVarDeclInit(EvalInfo &Info, const Expr *E,
unsigned Version, APValue *&Result) {
// C++23 [expr.const]p8 If we have a reference type allow unknown references
// and pointers.
- bool AllowConstexprUnknown =
- Info.getLangOpts().CPlusPlus23 && VD->getType()->isReferenceType();
+ bool AllowConstexprUnknown = VD->getType()->isReferenceType();
APValue::LValueBase Base(VD, Frame ? Frame->Index : 0, Version);
@@ -8893,8 +8892,7 @@ bool LValueExprEvaluator::VisitDeclRefExpr(const DeclRefExpr *E) {
bool LValueExprEvaluator::VisitVarDecl(const Expr *E, const VarDecl *VD) {
// C++23 [expr.const]p8 If we have a reference type allow unknown references
// and pointers.
- bool AllowConstexprUnknown =
- Info.getLangOpts().CPlusPlus23 && VD->getType()->isReferenceType();
+ bool AllowConstexprUnknown = VD->getType()->isReferenceType();
// If we are within a lambda's call operator, check whether the 'VD' referred
// to within 'E' actually represents a lambda-capture that maps to a
// data-member/field within the closure object, and if so, evaluate to the
|
Looks like the differences are mainly that we don't emit the "unknown/invalid initializer" diagnostics anymore. |
@frederick-vs-ja AFAIK, this would be an extension, NOT a DR. We probably want to be reasonably conservative here, because there are known issues with the implementation |
You are right, I updated https://clang.llvm.org/cxx_status.html#cxx23 I still think we should wait a bit for the codegen bugs to be fixed first |
I am still recovering from being sick but I agree, we should probably hold off for a bit more. |
The reduction of diagnostic messages in OpenMP tests seems like a good thing to me. IMO there's no initialization in Edit: The behavioral change of clangd is also probably a good thing! |
Reduced testcase for the microsoft-abi-member-pointers.cpp failure:
This should produce an error; clang -std=c++23 currently accepts it. |
The other test changes look mostly okay, but worth investigating to see if we can improve the diagnostic notes for illegal uses of constexpr-unknown variables. |
Let's check the CI.