Author: Younan Zhang Date: 2023-12-01T15:20:04+08:00 New Revision: c1ad363e6eba308fa94c47374ee98b3c79693a35
URL: https://github.com/llvm/llvm-project/commit/c1ad363e6eba308fa94c47374ee98b3c79693a35 DIFF: https://github.com/llvm/llvm-project/commit/c1ad363e6eba308fa94c47374ee98b3c79693a35.diff LOG: [clang] Use the materialized temporary's type while creating the APValue (#73355) See https://github.com/llvm/llvm-project/issues/72025 for the bug and its diagnosis. Added: clang/test/SemaCXX/pr72025.cpp Modified: clang/docs/ReleaseNotes.rst clang/lib/AST/ExprConstant.cpp Removed: ################################################################################ diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 748e2db2f850744..43ea6a3ffd6e6c2 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -789,6 +789,9 @@ Bug Fixes to C++ Support Fixes: (`#68769 <https://github.com/llvm/llvm-project/issues/68769>`_) +- Fixed a crash for C++98/03 while checking an ill-formed ``_Static_assert`` expression. + Fixes: (`#72025 <https://github.com/llvm/llvm-project/issues/72025>`_) + - Clang now defers the instantiation of explicit specifier until constraint checking completes (except deduction guides). Fixes: (`#59827 <https://github.com/llvm/llvm-project/issues/59827>`_) diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index 2aafe5bd5289fc2..986302e1fd225f2 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -8618,7 +8618,7 @@ bool LValueExprEvaluator::VisitMaterializeTemporaryExpr( Result.set(E); } else { Value = &Info.CurrentCall->createTemporary( - E, E->getType(), + E, Inner->getType(), E->getStorageDuration() == SD_FullExpression ? ScopeKind::FullExpression : ScopeKind::Block, Result); diff --git a/clang/test/SemaCXX/pr72025.cpp b/clang/test/SemaCXX/pr72025.cpp new file mode 100644 index 000000000000000..9f0a4b0f43630c5 --- /dev/null +++ b/clang/test/SemaCXX/pr72025.cpp @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -verify -std=c++03 -fsyntax-only %s +struct V { + char c[2]; + banana V() : c("i") {} // expected-error {{unknown type name}} + // expected-error@-1 {{constructor cannot have a return type}} +}; + +_Static_assert(V().c[0], ""); // expected-error {{is not an integral constant expression}} + _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits