[PATCH] D132136: [clang] Perform implicit lvalue-to-rvalue cast with new interpreter
Timm Bäder via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 25 21:39:50 PDT 2022
tbaeder updated this revision to Diff 455792.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D132136/new/
https://reviews.llvm.org/D132136
Files:
clang/lib/AST/ExprConstant.cpp
clang/test/AST/Interp/literals.cpp
Index: clang/test/AST/Interp/literals.cpp
===================================================================
--- clang/test/AST/Interp/literals.cpp
+++ clang/test/AST/Interp/literals.cpp
@@ -11,6 +11,7 @@
static_assert(number == 10, "");
static_assert(number != 10, ""); // expected-error{{failed}} \
// ref-error{{failed}} \
+ // expected-note{{evaluates to}} \
// ref-note{{evaluates to}}
constexpr bool getTrue() { return true; }
Index: clang/lib/AST/ExprConstant.cpp
===================================================================
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -14934,25 +14934,27 @@
/// lvalue-to-rvalue cast if it is an lvalue.
static bool EvaluateAsRValue(EvalInfo &Info, const Expr *E, APValue &Result) {
assert(!E->isValueDependent());
+
+ if (E->getType().isNull())
+ return false;
+
+ if (!CheckLiteralType(Info, E))
+ return false;
+
if (Info.EnableNewConstInterp) {
if (!Info.Ctx.getInterpContext().evaluateAsRValue(Info, E, Result))
return false;
} else {
- if (E->getType().isNull())
- return false;
-
- if (!CheckLiteralType(Info, E))
- return false;
-
if (!::Evaluate(Result, Info, E))
return false;
+ }
- if (E->isGLValue()) {
- LValue LV;
- LV.setFrom(Info.Ctx, Result);
- if (!handleLValueToRValueConversion(Info, E, E->getType(), LV, Result))
- return false;
- }
+ // Implicit lvalue-to-rvalue cast.
+ if (E->isGLValue()) {
+ LValue LV;
+ LV.setFrom(Info.Ctx, Result);
+ if (!handleLValueToRValueConversion(Info, E, E->getType(), LV, Result))
+ return false;
}
// Check this core constant expression is a constant expression.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D132136.455792.patch
Type: text/x-patch
Size: 1814 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220826/dae15e83/attachment.bin>
More information about the cfe-commits
mailing list