From patchwork Sun Sep 11 18:58:18 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 114248 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 9F6B2B727E for ; Mon, 12 Sep 2011 05:01:21 +1000 (EST) Received: (qmail 13256 invoked by alias); 11 Sep 2011 19:01:19 -0000 Received: (qmail 13239 invoked by uid 22791); 11 Sep 2011 19:01:16 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (194.98.77.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 11 Sep 2011 19:01:03 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 1DCC0CB02B0 for ; Sun, 11 Sep 2011 21:01:04 +0200 (CEST) Received: from mel.act-europe.fr ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id K+S-2BjYAgod for ; Sun, 11 Sep 2011 21:00:53 +0200 (CEST) Received: from [192.168.1.2] (bon31-9-83-155-120-49.fbx.proxad.net [83.155.120.49]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mel.act-europe.fr (Postfix) with ESMTP id D065CCB02BE for ; Sun, 11 Sep 2011 21:00:32 +0200 (CEST) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [Ada] Fix ICE on unchecked conversion from atomic record type Date: Sun, 11 Sep 2011 20:58:18 +0200 User-Agent: KMail/1.9.9 MIME-Version: 1.0 Message-Id: <201109112058.18654.ebotcazou@adacore.com> Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org This is a regression present on the mainline and 4.6 branch. Tested on i586-suse-linux, applied on the mainline and 4.6 branch. 2011-09-11 Eric Botcazou * gcc-interface/decl.c (maybe_pad_type): Do not try to change the form of an addressable type. * gcc-interface/trans.c (gnat_gimplify_expr) : New. Deal with those cases for which creating a temporary is mandatory. 2011-09-11 Eric Botcazou * gnat.dg/atomic5.ad[sb]: New test. Index: gcc-interface/decl.c =================================================================== --- gcc-interface/decl.c (revision 178762) +++ gcc-interface/decl.c (working copy) @@ -6521,6 +6521,7 @@ maybe_pad_type (tree type, tree size, un if (align != 0 && TREE_CODE (type) == RECORD_TYPE && TYPE_MODE (type) == BLKmode + && !TREE_ADDRESSABLE (type) && TREE_CODE (orig_size) == INTEGER_CST && !TREE_OVERFLOW (orig_size) && compare_tree_int (orig_size, MAX_FIXED_MODE_SIZE) <= 0 Index: gcc-interface/trans.c =================================================================== --- gcc-interface/trans.c (revision 178763) +++ gcc-interface/trans.c (working copy) @@ -6446,6 +6446,28 @@ gnat_gimplify_expr (tree *expr_p, gimple return GS_UNHANDLED; + case VIEW_CONVERT_EXPR: + op = TREE_OPERAND (expr, 0); + + /* If we are view-converting a CONSTRUCTOR or a call from an aggregate + type to a scalar one, explicitly create the local temporary. That's + required if the type is passed by reference. */ + if ((TREE_CODE (op) == CONSTRUCTOR || TREE_CODE (op) == CALL_EXPR) + && AGGREGATE_TYPE_P (TREE_TYPE (op)) + && !AGGREGATE_TYPE_P (TREE_TYPE (expr))) + { + tree mod, new_var = create_tmp_var_raw (TREE_TYPE (op), "C"); + gimple_add_tmp_var (new_var); + + mod = build2 (INIT_EXPR, TREE_TYPE (new_var), new_var, op); + gimplify_and_add (mod, pre_p); + + TREE_OPERAND (expr, 0) = new_var; + return GS_OK; + } + + return GS_UNHANDLED; + case DECL_EXPR: op = DECL_EXPR_DECL (expr);