Fznamznon updated this revision to Diff 508524. Fznamznon added a comment. Rebase, maybe this will get "pre-commit" started
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 @@ -230,6 +230,9 @@ antecipation of `CWG2563 <https://cplusplus.github.io/CWG/issues/2563.html>_`. - Fix highlighting issue with ``_Complex`` and initialization list with more than 2 items. (`#61518 <https://github.com/llvm/llvm-project/issues/61518>`_) +- 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 @@ -230,6 +230,9 @@ antecipation of `CWG2563 <https://cplusplus.github.io/CWG/issues/2563.html>_`. - Fix highlighting issue with ``_Complex`` and initialization list with more than 2 items. (`#61518 <https://github.com/llvm/llvm-project/issues/61518>`_) +- 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 cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits