[PATCH] D146801: [clang] Fix consteval initializers of temporaries
Mariya Podchishchaeva via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 28 04:42:23 PDT 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rG83c90e623a30: [clang] Fix consteval initializers of temporaries (authored by Fznamznon).
Changed prior to commit:
https://reviews.llvm.org/D146801?vs=508524&id=508963#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D146801/new/
https://reviews.llvm.org/D146801
Files:
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaExprCXX.cpp
clang/test/SemaCXX/cxx2a-consteval.cpp
Index: clang/test/SemaCXX/cxx2a-consteval.cpp
===================================================================
--- clang/test/SemaCXX/cxx2a-consteval.cpp
+++ clang/test/SemaCXX/cxx2a-consteval.cpp
@@ -1050,3 +1050,18 @@
}
}
+
+namespace GH60286 {
+
+struct A {
+ int i = 0;
+
+ consteval A() {}
+ A(const A&) { i = 1; }
+ consteval int f() { return i; }
+};
+
+constexpr auto B = A{A{}}.f();
+static_assert(B == 0);
+
+}
Index: clang/lib/Sema/SemaExprCXX.cpp
===================================================================
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -1590,6 +1590,9 @@
Expr *Inner = Result.get();
if (CXXBindTemporaryExpr *BTE = dyn_cast_or_null<CXXBindTemporaryExpr>(Inner))
Inner = BTE->getSubExpr();
+ if (auto *CE = dyn_cast<ConstantExpr>(Inner);
+ CE && CE->isImmediateInvocation())
+ Inner = CE->getSubExpr();
if (!isa<CXXTemporaryObjectExpr>(Inner) &&
!isa<CXXScalarValueInitExpr>(Inner)) {
// If we created a CXXTemporaryObjectExpr, that node also represents the
Index: clang/docs/ReleaseNotes.rst
===================================================================
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -238,6 +238,9 @@
the initializer, so it behaves consistently with other ``VarDecls`` and ends
on the last token of initializer, instead of right angle bracket of
the template argument list.
+- Fix false-positive diagnostic issued for consteval initializers of temporary
+ objects.
+ (`#60286 <https://github.com/llvm/llvm-project/issues/60286>`_)
Bug Fixes to Compiler Builtins
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D146801.508963.patch
Type: text/x-patch
Size: 1661 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230328/09198bd3/attachment-0001.bin>
More information about the cfe-commits
mailing list