Skip to content

Commit c1ad363

Browse files
authored
[clang] Use the materialized temporary's type while creating the APValue (#73355)
See #72025 for the bug and its diagnosis.
1 parent 5ecb37b commit c1ad363

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,9 @@ Bug Fixes to C++ Support
789789
Fixes:
790790
(`#68769 <https://github.com/llvm/llvm-project/issues/68769>`_)
791791

792+
- Fixed a crash for C++98/03 while checking an ill-formed ``_Static_assert`` expression.
793+
Fixes: (`#72025 <https://github.com/llvm/llvm-project/issues/72025>`_)
794+
792795
- Clang now defers the instantiation of explicit specifier until constraint checking
793796
completes (except deduction guides). Fixes:
794797
(`#59827 <https://github.com/llvm/llvm-project/issues/59827>`_)

clang/lib/AST/ExprConstant.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8618,7 +8618,7 @@ bool LValueExprEvaluator::VisitMaterializeTemporaryExpr(
86188618
Result.set(E);
86198619
} else {
86208620
Value = &Info.CurrentCall->createTemporary(
8621-
E, E->getType(),
8621+
E, Inner->getType(),
86228622
E->getStorageDuration() == SD_FullExpression ? ScopeKind::FullExpression
86238623
: ScopeKind::Block,
86248624
Result);

clang/test/SemaCXX/pr72025.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// RUN: %clang_cc1 -verify -std=c++03 -fsyntax-only %s
2+
struct V {
3+
char c[2];
4+
banana V() : c("i") {} // expected-error {{unknown type name}}
5+
// expected-error@-1 {{constructor cannot have a return type}}
6+
};
7+
8+
_Static_assert(V().c[0], ""); // expected-error {{is not an integral constant expression}}
9+

0 commit comments

Comments
 (0)