From patchwork Fri Jun 14 16:50:51 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 251470 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 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 512122C008E for ; Sat, 15 Jun 2013 02:51:07 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:reply-to:mime-version :content-type; q=dns; s=default; b=sOE3vq2R6/Z2mmZwYrvK70vlRhq6h cK9Ca/py9rW3DB9Amitq7IfeufTBftXQUyT3PCDhq6lFK7hLM8f4JJVPZaGy+Q9O bwbXm5ex/WiepoIPKtDT8ciJPrLZoVRcVU3G5JXaf5SGZQCcfEowWDMTg6aR3ZV4 uQFENNT24hDEvQ= 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:date :from:to:cc:subject:message-id:reply-to:mime-version :content-type; s=default; bh=b/IWnrVFUO0wEgK3P9VpoBeeWK4=; b=H4M nvprR9hW8aobHHBLT6OAANszHgpmuVrsvow0NWHnzo6PArK7hOjFwHTYm1YNX5xP jP6rIsBBAwt42yFI7unOW7JLCEbZYBRa/WJNqkiif6/e95WShhNCSUiTicYFNcPF 9ELHXFvoO48S+OfXGDBbB/gFmRcDvCawJoH651W8= Received: (qmail 30071 invoked by alias); 14 Jun 2013 16:50:59 -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 30061 invoked by uid 89); 14 Jun 2013 16:50:59 -0000 X-Spam-SWARE-Status: No, score=-6.4 required=5.0 tests=AWL, BAYES_00, RCVD_IN_HOSTKARMA_W, RCVD_IN_HOSTKARMA_WL, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.1 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Fri, 14 Jun 2013 16:50:58 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r5EGovIT006139 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 14 Jun 2013 12:50:57 -0400 Received: from zalov.cz (vpn-52-247.rdu2.redhat.com [10.10.52.247]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r5EGotPS018190 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 14 Jun 2013 12:50:56 -0400 Received: from zalov.cz (localhost [127.0.0.1]) by zalov.cz (8.14.5/8.14.5) with ESMTP id r5EGosa8004120; Fri, 14 Jun 2013 18:50:54 +0200 Received: (from jakub@localhost) by zalov.cz (8.14.5/8.14.5/Submit) id r5EGorRr004119; Fri, 14 Jun 2013 18:50:53 +0200 Date: Fri, 14 Jun 2013 18:50:51 +0200 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Cc: Richard Henderson , Aldy Hernandez Subject: [gomp4] Small mappable type fixes Message-ID: <20130614165051.GM2336@tucnak.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Hi! This patch improves cp_omp_mappable_type, fixes reference to pointer based array sections, and diagnoses if map/to/from clauses don't have decls or array sections with mappable type. 2013-06-14 Jakub Jelinek * decl2.c (cp_omp_mappable_type): No longer static. Handle array types and recurse for FIELD_DECL types. * semantics.c (handle_omp_array_sections_1): Call convert_from_reference before testing for pointer_based_p. (finish_omp_clauses): Complain if OMP_CLAUSE_{MAP,TO,FROM} decls or array sections don't have cp_omp_mappable_type. * cp-tree.h (cp_omp_mappable_type): New prototype. Jakub --- gcc/cp/decl2.c.jj 2013-05-29 10:05:42.000000000 +0200 +++ gcc/cp/decl2.c 2013-06-14 12:09:18.284393933 +0200 @@ -1334,12 +1334,15 @@ cp_check_const_attributes (tree attribut } /* Return true if TYPE is an OpenMP mappable type. */ -static bool +bool cp_omp_mappable_type (tree type) { /* Mappable type has to be complete. */ if (type == error_mark_node || !COMPLETE_TYPE_P (type)) return false; + /* Arrays have mappable type if the elements have mappable type. */ + while (TREE_CODE (type) == ARRAY_TYPE) + type = TREE_TYPE (type); /* A mappable type cannot contain virtual members. */ if (CLASS_TYPE_P (type) && CLASSTYPE_VTABLES (type)) return false; @@ -1350,6 +1353,10 @@ cp_omp_mappable_type (tree type) for (field = TYPE_FIELDS (type); field; field = DECL_CHAIN (field)) if (TREE_CODE (field) == VAR_DECL) return false; + /* All fields must have mappable types. */ + else if (TREE_CODE (field) == FIELD_DECL + && !cp_omp_mappable_type (TREE_TYPE (field))) + return false; } return true; } --- gcc/cp/semantics.c.jj 2013-06-12 15:00:11.000000000 +0200 +++ gcc/cp/semantics.c 2013-06-14 12:09:18.287394537 +0200 @@ -4122,11 +4122,11 @@ handle_omp_array_sections_1 (tree c, tre omp_clause_code_name[OMP_CLAUSE_CODE (c)]); return error_mark_node; } + t = convert_from_reference (t); if (!processing_template_decl && POINTER_TYPE_P (TREE_TYPE (t)) && OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP) pointer_based_p = true; - t = convert_from_reference (t); return t; } @@ -4921,6 +4921,18 @@ finish_omp_clauses (tree clauses) { if (handle_omp_array_sections (c)) remove = true; + else + { + t = OMP_CLAUSE_DECL (c); + if (!cp_omp_mappable_type (TREE_TYPE (t))) + { + error_at (OMP_CLAUSE_LOCATION (c), + "array section does not have mappable type " + "in %qs clause", + omp_clause_code_name[OMP_CLAUSE_CODE (c)]); + remove = true; + } + } break; } if (t == error_mark_node) @@ -4947,6 +4959,16 @@ finish_omp_clauses (tree clauses) && TREE_CODE (TREE_TYPE (t)) != REFERENCE_TYPE && !cxx_mark_addressable (t)) remove = true; + else if (!cp_omp_mappable_type ((TREE_CODE (TREE_TYPE (t)) + == REFERENCE_TYPE) + ? TREE_TYPE (TREE_TYPE (t)) + : TREE_TYPE (t))) + { + error_at (OMP_CLAUSE_LOCATION (c), + "%qD does not have a mappable type in %qs clause", t, + omp_clause_code_name[OMP_CLAUSE_CODE (c)]); + remove = true; + } else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP) break; else if (bitmap_bit_p (&generic_head, DECL_UID (t))) --- gcc/cp/cp-tree.h.jj 2013-05-29 10:05:42.000000000 +0200 +++ gcc/cp/cp-tree.h 2013-06-13 12:26:37.480571572 +0200 @@ -5297,6 +5296,7 @@ extern void note_vague_linkage_fn (tree extern tree build_artificial_parm (tree, tree); extern bool possibly_inlined_p (tree); extern int parm_index (tree); +extern bool cp_omp_mappable_type (tree); /* in error.c */ extern void init_error (void);