diff options
author | Iain Buclaw <ibuclaw@gdcproject.org> | 2020-07-22 09:50:38 +0200 |
---|---|---|
committer | Iain Buclaw <ibuclaw@gdcproject.org> | 2020-08-04 17:02:56 +0200 |
commit | 2ac51bdf63b0e17d1b9974f30303fb24e3cbc83d (patch) | |
tree | 78a0b25b1cb01fd3bf17716064ac421dd5f04adf /gcc/function.h | |
parent | 19fad46721af338b24aff48127ae654673bffa7b (diff) | |
download | gcc-2ac51bdf63b0e17d1b9974f30303fb24e3cbc83d.zip gcc-2ac51bdf63b0e17d1b9974f30303fb24e3cbc83d.tar.gz gcc-2ac51bdf63b0e17d1b9974f30303fb24e3cbc83d.tar.bz2 |
d: Fix struct literals that have non-deterministic hash values (PR96153)
Adds code generation for generating a temporary for, and pre-filling
struct and array literals with zeroes before assigning, so that
alignment holes don't cause objects to produce a non-deterministic hash
value. A new field has been added to the expression visitor to track
whether the result is being generated for another literal, so that
memset() is only called once on the top-level literal expression, and
not for nesting struct or arrays.
gcc/d/ChangeLog:
PR d/96153
* d-tree.h (build_expr): Add literalp argument.
* expr.cc (ExprVisitor): Add literalp_ field.
(ExprVisitor::ExprVisitor): Initialize literalp_.
(ExprVisitor::visit (AssignExp *)): Call memset() on blits where RHS
is a struct literal. Elide assignment if initializer is all zeroes.
(ExprVisitor::visit (CastExp *)): Forward literalp_ to generation of
subexpression.
(ExprVisitor::visit (AddrExp *)): Likewise.
(ExprVisitor::visit (ArrayLiteralExp *)): Use memset() to pre-fill
object with zeroes. Set literalp in subexpressions.
(ExprVisitor::visit (StructLiteralExp *)): Likewise.
(ExprVisitor::visit (TupleExp *)): Set literalp in subexpressions.
(ExprVisitor::visit (VectorExp *)): Likewise.
(ExprVisitor::visit (VectorArrayExp *)): Likewise.
(build_expr): Forward literal_p to ExprVisitor.
gcc/testsuite/ChangeLog:
PR d/96153
* gdc.dg/pr96153.d: New test.
Diffstat (limited to 'gcc/function.h')
0 files changed, 0 insertions, 0 deletions