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
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
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
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits