From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 50213 invoked by alias); 29 Apr 2016 09:01:39 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 50202 invoked by uid 89); 29 Apr 2016 09:01:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1465 X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Fri, 29 Apr 2016 09:01:30 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 4B730AD6E; Fri, 29 Apr 2016 09:01:27 +0000 (UTC) Date: Fri, 29 Apr 2016 09:01:00 -0000 From: Richard Biener To: gcc-patches@gcc.gnu.org cc: jason@redhat.com Subject: [PATCH][C++] Build DECL_EXPRs for anonymous VLAs Message-ID: User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-SW-Source: 2016-04/txt/msg01951.txt.bz2 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 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) {