From patchwork Thu Nov 12 14:03:42 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 543356 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 66893141405 for ; Fri, 13 Nov 2015 01:03:59 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=fthnA9iY; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=scKjglk9ZFrAYylQitdAceoJ9wmZ6i0Br2uU2oroJZy1HFEpQ8 Uo1ffG5xXgUbKSQl44NErGrW583V67p8E/2Wp7oZJj/jE/zYgcddY+SnZ2VGA5y2 TClmOV6lNwRho2xt8aTu36Y/xvcdTrCPY6xunNGKPdy17Ed6/t1c2n6qg= 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:to:cc :from:subject:message-id:date:mime-version:content-type; s= default; bh=kmPHgECOg5X98bIGkpvGynQ0hW8=; b=fthnA9iYvVQzE+WGmMWa elkRzY7qXKoRtaWG5kCG0pq0RdaWWYX7t4mWVYjuN+R6jhPo4eYiQf2HpjG6pDsc WrdeHWUlhoXM6kliLw7vOUiCvf5rUyAu8Qc299ckafROD+zvB7MXgCkY5Jy+FEsp I5gkAXqO3u7bMrmRknfE53A= Received: (qmail 4192 invoked by alias); 12 Nov 2015 14:03:48 -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 4182 invoked by uid 89); 12 Nov 2015 14:03:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=BAYES_00, FREEMAIL_FROM, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=no version=3.3.2 X-HELO: mail-vk0-f41.google.com Received: from mail-vk0-f41.google.com (HELO mail-vk0-f41.google.com) (209.85.213.41) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Thu, 12 Nov 2015 14:03:46 +0000 Received: by vkgy188 with SMTP id y188so10529356vkg.1 for ; Thu, 12 Nov 2015 06:03:43 -0800 (PST) X-Received: by 10.31.152.19 with SMTP id a19mr3414139vke.53.1447337023800; Thu, 12 Nov 2015 06:03:43 -0800 (PST) Received: from ?IPv6:2601:181:c000:c497:a2a8:cdff:fe3e:b48? ([2601:181:c000:c497:a2a8:cdff:fe3e:b48]) by smtp.googlemail.com with ESMTPSA id t196sm2573638vke.27.2015.11.12.06.03.43 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Nov 2015 06:03:43 -0800 (PST) To: GCC Patches Cc: Thomas Schwinge , Cesar Philippidis From: Nathan Sidwell Subject: [gomp4] remove c++ reference restriction Message-ID: <56449C3E.4040108@acm.org> Date: Thu, 12 Nov 2015 09:03:42 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 I've applied this to gomp4 branch. It removes the machinery concerning c++ references. The openacc std makes no mention of such a type, so originally we were not permitting the type. But, (a) OpenMP supports them, which suggests openacc wishes to (b) Fortran already has reference types that need supporting (c) it's more work to not support them, by modifying the mappable_type hook. nathan 2015-11-12 Nathan Sidwell * langhooks-def.h (omp_mappable_type): Remove oacc arg. * langhooks.h (lhd_omp_mappable_type): Likewise. * langhooks.c (lhd_omp_mappable_type): Likswise. * gimplify.c (omp_notice_variable): Adjust omp_mappable_type call. c/ * c-typeck.c (c_finish_omp_clauses): Adjust omp_mappable_type calls. * c-decl.c (c_decl_attributes): Likewise. testsuite/ * g++.dg/goacc/reference.C: Adjust. cp/ * semantics.c (finish_ommp_clauses): Adjust omp_mappable_type calls. * decl2.c (cp_omp_mappable_type): Remove oacc arg and processing. * cp-tree.h (cp_omp_mappable_type): Remove oacc arg. oIndex: gimplify.c =================================================================== --- gimplify.c (revision 230177) +++ gimplify.c (working copy) @@ -6106,9 +6106,7 @@ omp_notice_variable (struct gimplify_omp && lang_hooks.decls.omp_privatize_by_reference (decl)) type = TREE_TYPE (type); if (nflags == flags - && !lang_hooks.types.omp_mappable_type (type, - (ctx->region_type - & ORT_ACC) != 0)) + && !lang_hooks.types.omp_mappable_type (type)) { error ("%qD referenced in target region does not have " "a mappable type", decl); Index: langhooks.c =================================================================== --- langhooks.c (revision 230177) +++ langhooks.c (working copy) @@ -525,7 +525,7 @@ lhd_omp_firstprivatize_type_sizes (struc /* Return true if TYPE is an OpenMP mappable type. */ bool -lhd_omp_mappable_type (tree type, bool oacc ATTRIBUTE_UNUSED) +lhd_omp_mappable_type (tree type) { /* Mappable type has to be complete. */ if (type == error_mark_node || !COMPLETE_TYPE_P (type)) Index: langhooks.h =================================================================== --- langhooks.h (revision 230177) +++ langhooks.h (working copy) @@ -112,7 +112,7 @@ struct lang_hooks_for_types void (*omp_firstprivatize_type_sizes) (struct gimplify_omp_ctx *, tree); /* Return true if TYPE is a mappable type. */ - bool (*omp_mappable_type) (tree type, bool oacc); + bool (*omp_mappable_type) (tree type); /* Return TRUE if TYPE1 and TYPE2 are identical for type hashing purposes. Called only after doing all language independent checks. Index: testsuite/g++.dg/goacc/reference.C =================================================================== --- testsuite/g++.dg/goacc/reference.C (revision 230177) +++ testsuite/g++.dg/goacc/reference.C (working copy) @@ -4,7 +4,7 @@ int test1 (int &ref) { -#pragma acc kernels copy (ref) // { dg-error "reference types are not supported in OpenACC" } +#pragma acc kernels copy (ref) { ref = 10; } @@ -16,12 +16,12 @@ test2 (int &ref) int b; #pragma acc kernels copyout (b) { - b = ref + 10; // { dg-error "referenced in target region does not have a mappable type" } + b = ref + 10; } #pragma acc parallel copyout (b) { - b = ref + 10; // { dg-error "referenced in target region does not have a mappable type" } + b = ref + 10; } ref = b; @@ -33,7 +33,7 @@ main() int a = 0; int &ref_a = a; - #pragma acc parallel copy (a, ref_a) // { dg-error "reference types are not supported in OpenACC" } + #pragma acc parallel copy (a, ref_a) { ref_a = 5; } Index: c/c-typeck.c =================================================================== --- c/c-typeck.c (revision 230177) +++ c/c-typeck.c (working copy) @@ -12863,8 +12863,7 @@ c_finish_omp_clauses (tree clauses, bool else { t = OMP_CLAUSE_DECL (c); - if (!lang_hooks.types.omp_mappable_type (TREE_TYPE (t), - is_oacc)) + if (!lang_hooks.types.omp_mappable_type (TREE_TYPE (t))) { error_at (OMP_CLAUSE_LOCATION (c), "array section does not have mappable type " @@ -12916,8 +12915,7 @@ c_finish_omp_clauses (tree clauses, bool t, omp_clause_code_name[OMP_CLAUSE_CODE (c)]); remove = true; } - else if (!lang_hooks.types.omp_mappable_type (TREE_TYPE (t), - is_oacc)) + else if (!lang_hooks.types.omp_mappable_type (TREE_TYPE (t))) { error_at (OMP_CLAUSE_LOCATION (c), "%qE does not have a mappable type in %qs clause", @@ -12967,8 +12965,7 @@ c_finish_omp_clauses (tree clauses, bool || (OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_FORCE_DEVICEPTR))) && t == OMP_CLAUSE_DECL (c) - && !lang_hooks.types.omp_mappable_type (TREE_TYPE (t), - is_oacc)) + && !lang_hooks.types.omp_mappable_type (TREE_TYPE (t))) { error_at (OMP_CLAUSE_LOCATION (c), "%qD does not have a mappable type in %qs clause", t, @@ -13044,7 +13041,7 @@ c_finish_omp_clauses (tree clauses, bool omp_clause_code_name[OMP_CLAUSE_CODE (c)]); remove = true; } - else if (!lang_hooks.types.omp_mappable_type (TREE_TYPE (t), is_oacc)) + else if (!lang_hooks.types.omp_mappable_type (TREE_TYPE (t))) { error_at (OMP_CLAUSE_LOCATION (c), "%qD does not have a mappable type in %qs clause", t, Index: c/c-decl.c =================================================================== --- c/c-decl.c (revision 230177) +++ c/c-decl.c (working copy) @@ -4411,7 +4411,7 @@ c_decl_attributes (tree *node, tree attr || TREE_CODE (*node) == FUNCTION_DECL)) { if (VAR_P (*node) - && !lang_hooks.types.omp_mappable_type (TREE_TYPE (*node), false)) + && !lang_hooks.types.omp_mappable_type (TREE_TYPE (*node))) error ("%q+D in declare target directive does not have mappable type", *node); else Index: langhooks-def.h =================================================================== --- langhooks-def.h (revision 230177) +++ langhooks-def.h (working copy) @@ -79,7 +79,7 @@ extern void lhd_omp_finish_clause (tree, struct gimplify_omp_ctx; extern void lhd_omp_firstprivatize_type_sizes (struct gimplify_omp_ctx *, tree); -extern bool lhd_omp_mappable_type (tree, bool); +extern bool lhd_omp_mappable_type (tree); #define LANG_HOOKS_NAME "GNU unknown" #define LANG_HOOKS_IDENTIFIER_SIZE sizeof (struct lang_identifier) Index: cp/semantics.c =================================================================== --- cp/semantics.c (revision 230177) +++ cp/semantics.c (working copy) @@ -6523,7 +6523,7 @@ finish_omp_clauses (tree clauses, bool i t = OMP_CLAUSE_DECL (c); if (TREE_CODE (t) != TREE_LIST && !type_dependent_expression_p (t) - && !cp_omp_mappable_type (TREE_TYPE (t), is_oacc)) + && !cp_omp_mappable_type (TREE_TYPE (t))) { error_at (OMP_CLAUSE_LOCATION (c), "array section does not have mappable type " @@ -6588,7 +6588,7 @@ finish_omp_clauses (tree clauses, bool i t, omp_clause_code_name[OMP_CLAUSE_CODE (c)]); remove = true; } - else if (!cp_omp_mappable_type (TREE_TYPE (t), is_oacc)) + else if (!cp_omp_mappable_type (TREE_TYPE (t))) { error_at (OMP_CLAUSE_LOCATION (c), "%qE does not have a mappable type in %qs clause", @@ -6658,7 +6658,7 @@ finish_omp_clauses (tree clauses, bool i && !cp_omp_mappable_type (((TREE_CODE (TREE_TYPE (t)) == REFERENCE_TYPE) ? TREE_TYPE (TREE_TYPE (t)) - : TREE_TYPE (t)), is_oacc)) + : TREE_TYPE (t)))) { error_at (OMP_CLAUSE_LOCATION (c), "%qD does not have a mappable type in %qs clause", t, @@ -6781,7 +6781,7 @@ finish_omp_clauses (tree clauses, bool i omp_clause_code_name[OMP_CLAUSE_CODE (c)]); remove = true; } - else if (!cp_omp_mappable_type (TREE_TYPE (t), is_oacc)) + else if (!cp_omp_mappable_type (TREE_TYPE (t))) { error_at (OMP_CLAUSE_LOCATION (c), "%qD does not have a mappable type in %qs clause", t, Index: cp/decl2.c =================================================================== --- cp/decl2.c (revision 230177) +++ cp/decl2.c (working copy) @@ -1403,7 +1403,7 @@ cp_check_const_attributes (tree attribut /* Return true if TYPE is an OpenMP mappable type. */ bool -cp_omp_mappable_type (tree type, bool oacc) +cp_omp_mappable_type (tree type) { /* Mappable type has to be complete. */ if (type == error_mark_node || !COMPLETE_TYPE_P (type)) @@ -1423,11 +1423,9 @@ cp_omp_mappable_type (tree type, bool oa return false; /* All fields must have mappable types. */ else if (TREE_CODE (field) == FIELD_DECL - && !cp_omp_mappable_type (TREE_TYPE (field), oacc)) + && !cp_omp_mappable_type (TREE_TYPE (field))) return false; } - if (oacc && TREE_CODE (type) == REFERENCE_TYPE) - return false; return true; } @@ -1452,7 +1450,7 @@ cplus_decl_attributes (tree *decl, tree *decl); else if (!processing_template_decl && VAR_P (*decl) - && !cp_omp_mappable_type (TREE_TYPE (*decl), false)) + && !cp_omp_mappable_type (TREE_TYPE (*decl))) error ("%q+D in declare target directive does not have mappable type", *decl); else Index: cp/cp-tree.h =================================================================== --- cp/cp-tree.h (revision 230177) +++ cp/cp-tree.h (working copy) @@ -5790,7 +5790,7 @@ extern bool possibly_inlined_p (tree); extern int parm_index (tree); extern tree vtv_start_verification_constructor_init_function (void); extern tree vtv_finish_verification_constructor_init_function (tree); -extern bool cp_omp_mappable_type (tree, bool); +extern bool cp_omp_mappable_type (tree); /* in error.c */ extern const char *type_as_string (tree, int);