Add a DECL_EXPR for VLA pointer casts (PR 84305)

Programming / Compilers / GCC - rsandifo [138bc75d-0d04-0410-961f-82ee72b054a4] - 13 February 2018 10:28 EST

This PR was about a case in which we ended up with a MULT_EXPR that was shared between an ungimplified VLA type and a pointer calculation. The SSA names used in the pointer calculation were later freed, but they were still there in the VLA, and caused an ICE when remapping the types during inlinling.

The fix is to add a DECL_EXPR that forces the VLA type sizes to be gimplified too, but the tricky part is deciding where. As the comment in grokdeclarator says, we can't just add it to the statement list, since the size might only be conditionally evaluated. It might also end up being evaluated out of sequence.

The patch gets around that by putting the DECL_EXPR in a BIND_EXPR and adding the BIND_EXPR to the list of things that need to be evaluated for the declarator.

2018-02-13 Richard Sandiford

gcc/c/ PR c/84305
- c-decl.c (grokdeclarator): Create an anonymous TYPE_DECL in PARM and TYPENAME contexts too, but attach it to a BIND_EXPR and include the BIND_EXPR in the list of things that need to be pre-evaluated.

gcc/testsuite/ PR c/84305
- gcc.c-torture/compile/pr84305.c: New test.

20ebaa3da2b Add a DECL_EXPR for VLA pointer casts (PR 84305)
gcc/c/ChangeLog | 8 ++++
gcc/c/c-decl.c | 53 ++++++++++++++++++++-------
gcc/testsuite/ChangeLog | 5 +++
gcc/testsuite/gcc.c-torture/compile/pr84305.c | 4 ++
4 files changed, 56 insertions(+), 14 deletions(-)


  • Share