From patchwork Mon Dec 9 15:02:53 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schmidt X-Patchwork-Id: 299083 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id B74422C0092 for ; Tue, 10 Dec 2013 02:03:25 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:references :in-reply-to:content-type; q=dns; s=default; b=ujKH587JolTgd0CsH Cx4juwfhaF7XQ16pbUfkpPxHwOissQjMSfIc+78CnqtG/JBZUN4FLcEkXvMioMq5 nJwMBgPUlH6sCdjWUEUwQHR57dA5sLsGzpsolvyDGe7p231Zds9085nHzxKWlzLe lrTeIc3DAWejwKlLovO+8ww4ao= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:references :in-reply-to:content-type; s=default; bh=k0t+mpWQXJabRl58/nixAW5 ovFc=; b=WwPdcNxRarAvIpRwU349gLOp5/kVGPtp0KEb5Veb7UTO1tBJ+5I4aEn H2xQA/Rg/O4DC9zAvbitAcZlq561Ohib2xlKMSZuCk2VYsocPaWKAayglBtewGX/ yCbgIRlOg2UoD4LJONyBvC/9yU47qrDFvDnSvplivh20zA/MLMyg= Received: (qmail 1012 invoked by alias); 9 Dec 2013 15:03:19 -0000 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 Received: (qmail 989 invoked by uid 89); 9 Dec 2013 15:03:18 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, T_FROM_12LTRDOM autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from Unknown (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 09 Dec 2013 15:03:17 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1Vq2MQ-0005pM-8U from Bernd_Schmidt@mentor.com for gcc-patches@gcc.gnu.org; Mon, 09 Dec 2013 07:03:02 -0800 Received: from SVR-IES-FEM-02.mgc.mentorg.com ([137.202.0.106]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Mon, 9 Dec 2013 07:03:02 -0800 Received: from [127.0.0.1] (137.202.0.76) by SVR-IES-FEM-02.mgc.mentorg.com (137.202.0.106) with Microsoft SMTP Server id 14.2.247.3; Mon, 9 Dec 2013 15:03:00 +0000 Message-ID: <52A5DB9D.50801@codesourcery.com> Date: Mon, 9 Dec 2013 16:02:53 +0100 From: Bernd Schmidt User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130926 Thunderbird/17.0.9 MIME-Version: 1.0 To: GCC Patches Subject: [gomp4, 10/23] Ensure address space gets set on array types References: <52A5D8D4.2030803@codesourcery.com> In-Reply-To: <52A5D8D4.2030803@codesourcery.com> Most of the compiler expects TYPE_ADDR_SPACE to be valid for things like initializing a MEM. The C frontend does not set it for arrays, which seems like an oversight caused by not setting other type qualifiers for array types. gcc/ * tree.h (set_type_quals): Declare. * tree.c (set_type_quals): No longer static. gcc/c/ * c-typeck.c (c_build_qualified_type): Ensure arrays get the correct TYPE_ADDR_SPACE. gcc/c-family/ * c-common.c (complete_array_type): Likewise. ------------------------------------------------------------------------ Index: gcc/c-family/c-common.c =================================================================== --- gcc/c-family/c-common.c (revision 422353) +++ gcc/c-family/c-common.c (revision 422354) @@ -9997,6 +9997,8 @@ complete_array_type (tree *ptype, tree i of using build_array_type to create a new type preserves all of the TYPE_LANG_FLAG_? bits that the front end may have set. */ main_type = build_distinct_type_copy (TYPE_MAIN_VARIANT (type)); + set_type_quals (main_type, KEEP_QUAL_ADDR_SPACE (quals)); + TREE_TYPE (main_type) = unqual_elt; TYPE_DOMAIN (main_type) = build_range_type (TREE_TYPE (maxindex), Index: gcc/c/c-typeck.c =================================================================== --- gcc/c/c-typeck.c (revision 422353) +++ gcc/c/c-typeck.c (revision 422354) @@ -11748,6 +11748,7 @@ c_build_qualified_type (tree type, int t t = build_variant_type_copy (type); TREE_TYPE (t) = element_type; + set_type_quals (t, KEEP_QUAL_ADDR_SPACE (type_quals)); if (TYPE_STRUCTURAL_EQUALITY_P (element_type) || (domain && TYPE_STRUCTURAL_EQUALITY_P (domain))) Index: gcc/tree.c =================================================================== --- gcc/tree.c (revision 422353) +++ gcc/tree.c (revision 422354) @@ -205,7 +205,6 @@ static GTY ((if_marked ("tree_priority_m param_is (struct tree_priority_map))) htab_t init_priority_for_decl; -static void set_type_quals (tree, int); static int type_hash_eq (const void *, const void *); static hashval_t type_hash_hash (const void *); static hashval_t int_cst_hash_hash (const void *); @@ -6076,7 +6075,7 @@ handle_dll_attribute (tree * pnode, tree /* Set the type qualifiers for TYPE to TYPE_QUALS, which is a bitmask of the various TYPE_QUAL values. */ -static void +void set_type_quals (tree type, int type_quals) { TYPE_READONLY (type) = (type_quals & TYPE_QUAL_CONST) != 0; Index: gcc/tree.h =================================================================== --- gcc/tree.h (revision 422353) +++ gcc/tree.h (revision 422354) @@ -3785,6 +3785,9 @@ extern tree build_qualified_type (tree, extern tree build_aligned_type (tree, unsigned int); +/* Set the type qualifiers on a type. */ +extern void set_type_quals (tree, int); + /* Like build_qualified_type, but only deals with the `const' and `volatile' qualifiers. This interface is retained for backwards compatibility with the various front-ends; new code should use