[clang] [clang] Use the materialized temporary's type while creating the APValue (PR #73355)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 24 10:07:38 PST 2023
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Younan Zhang (zyn0217)
<details>
<summary>Changes</summary>
See https://github.com/llvm/llvm-project/issues/72025 for the bug and its diagnosis.
---
Full diff: https://github.com/llvm/llvm-project/pull/73355.diff
3 Files Affected:
- (modified) clang/docs/ReleaseNotes.rst (+3)
- (modified) clang/lib/AST/ExprConstant.cpp (+1-1)
- (added) clang/test/SemaCXX/pr72025.cpp (+9)
``````````diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 74358219ba9fb22..d434d016907f815 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -691,6 +691,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 e16fec6109e744e..6c6ad12119d13c3 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -8607,7 +8607,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 at -1 {{constructor cannot have a return type}}
+};
+
+_Static_assert(V().c[0], ""); // expected-error {{is not an integral constant expression}}
+
``````````
</details>
https://github.com/llvm/llvm-project/pull/73355
More information about the cfe-commits
mailing list