From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 106088 invoked by alias); 9 Dec 2016 13:14:30 -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 106046 invoked by uid 89); 9 Dec 2016 13:14:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1418 X-HELO: foss.arm.com Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 09 Dec 2016 13:14:16 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B2A1D707; Fri, 9 Dec 2016 05:14:15 -0800 (PST) Received: from localhost (e105548-lin.manchester.arm.com [10.45.32.67]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5F6BB3F477 for ; Fri, 9 Dec 2016 05:14:15 -0800 (PST) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: [32/67] Check is_a before calling valid_pointer_mode References: <87h96dp8u6.fsf@e105548-lin.cambridge.arm.com> Date: Fri, 09 Dec 2016 13:14:00 -0000 In-Reply-To: <87h96dp8u6.fsf@e105548-lin.cambridge.arm.com> (Richard Sandiford's message of "Fri, 09 Dec 2016 12:48:01 +0000") Message-ID: <87mvg5jlcq.fsf@e105548-lin.cambridge.arm.com> User-Agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SW-Source: 2016-12/txt/msg00804.txt.bz2 A future patch will make valid_pointer_mode take a scalar_int_mode instead of a machine_mode. is_a <...> rather than as_a <...> is needed here because we're checking a mode supplied by the user. gcc/c-family/ 2016-11-24 Richard Sandiford Alan Hayward David Sherwood * c-attribs.c (handle_mode_attribute): Check for a scalar_int_mode before calling targetm.addr_space.valid_pointer_mode. diff --git a/gcc/c-family/c-attribs.c b/gcc/c-family/c-attribs.c index 4c4017a..14b43fe 100644 --- a/gcc/c-family/c-attribs.c +++ b/gcc/c-family/c-attribs.c @@ -1356,10 +1356,12 @@ handle_mode_attribute (tree *node, tree name, tree args, if (POINTER_TYPE_P (type)) { + scalar_int_mode addr_mode; addr_space_t as = TYPE_ADDR_SPACE (TREE_TYPE (type)); tree (*fn)(tree, machine_mode, bool); - if (!targetm.addr_space.valid_pointer_mode (mode, as)) + if (!is_a (mode, &addr_mode) + || !targetm.addr_space.valid_pointer_mode (addr_mode, as)) { error ("invalid pointer mode %qs", p); return NULL_TREE; @@ -1369,7 +1371,7 @@ handle_mode_attribute (tree *node, tree name, tree args, fn = build_pointer_type_for_mode; else fn = build_reference_type_for_mode; - typefm = fn (TREE_TYPE (type), mode, false); + typefm = fn (TREE_TYPE (type), addr_mode, false); } else {