Skip to content

Commit

Permalink
[clang] Use the materialized temporary's type while creating the APVa…
Browse files Browse the repository at this point in the history
…lue (#73355)

See #72025 for the bug and
its diagnosis.
  • Loading branch information
zyn0217 committed Dec 1, 2023
1 parent 5ecb37b commit c1ad363
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
3 changes: 3 additions & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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>`_)
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/AST/ExprConstant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
9 changes: 9 additions & 0 deletions clang/test/SemaCXX/pr72025.cpp
Original file line number Diff line number Diff line change
@@ -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}}

0 comments on commit c1ad363

Please sign in to comment.