This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH][C++] Build DECL_EXPRs for anonymous VLAs


The following makes sure that the gimplifier properly unshares the
type fields in anonymous VLA types by inserting a DECL_EXPR for
it instead of just forcing a TYPE_SIZE evaluation.

This avoids turning those fields in to garbage during gimplification.

Bootstrapped and tested on x86_64-unknown-linux-gnu.

Ok for trunk?

This fixes an ICE with c-c++-common/ubsan/pr59667.c when the gimplfier
is allowed to introduce SSA names.

Richard.

2016-04-29  Richard Biener  <rguenther@suse.de>

	cp/
	* decl.c (grokdeclarator): Properly insert a DECL_EXPR for
	anonymous VLAs.

Index: gcc/cp/decl.c
===================================================================
*** gcc/cp/decl.c.orig	2016-04-28 14:11:00.044581227 +0200
--- gcc/cp/decl.c	2016-04-28 14:11:08.116671106 +0200
*************** grokdeclarator (const cp_declarator *dec
*** 10393,10400 ****
  	      && (decl_context == NORMAL || decl_context == FIELD)
  	      && at_function_scope_p ()
  	      && variably_modified_type_p (type, NULL_TREE))
! 	    /* Force evaluation of the SAVE_EXPR.  */
! 	    finish_expr_stmt (TYPE_SIZE (type));
  
  	  if (declarator->kind == cdk_reference)
  	    {
--- 10393,10403 ----
  	      && (decl_context == NORMAL || decl_context == FIELD)
  	      && at_function_scope_p ()
  	      && variably_modified_type_p (type, NULL_TREE))
! 	    {
! 	      TYPE_NAME (type) = build_decl (UNKNOWN_LOCATION, TYPE_DECL,
! 					     NULL_TREE, type);
! 	      add_decl_expr (TYPE_NAME (type));
! 	    }
  
  	  if (declarator->kind == cdk_reference)
  	    {


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]