From patchwork Tue Jun 15 12:35:48 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 55652 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 EA12FB7D48 for ; Tue, 15 Jun 2010 22:35:49 +1000 (EST) Received: (qmail 30458 invoked by alias); 15 Jun 2010 12:35:48 -0000 Received: (qmail 30443 invoked by uid 22791); 15 Jun 2010 12:35:47 -0000 X-SWARE-Spam-Status: No, hits=-6.0 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 15 Jun 2010 12:35:40 +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.13.8/8.13.8) with ESMTP id o5FCZdqR024851 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 15 Jun 2010 08:35:39 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o5FCZcCw012757 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 15 Jun 2010 08:35:39 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [127.0.0.1]) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4) with ESMTP id o5FCZmYW013711 for ; Tue, 15 Jun 2010 14:35:48 +0200 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id o5FCZmh7013710 for gcc-patches@gcc.gnu.org; Tue, 15 Jun 2010 14:35:48 +0200 Date: Tue, 15 Jun 2010 14:35:48 +0200 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Subject: [committed] Fix Fortran DEFAULT(NONE) OpenMP diagnostics (PR fortran/44536) Message-ID: <20100615123548.GM7811@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-12-10) X-IsSubscribed: yes 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 Hi! Some dummy array args in Fortran FE are represented by a.0 etc. artificial vars, those shouldn't be predetermined shared. The rest of the changes (the new langhook) is just to avoid reporting that a.0 is used in OpenMP region (instead of a). Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk/4.5/4.4. 2010-06-15 Jakub Jelinek PR fortran/44536 * langhooks.h (struct lang_hooks_for_decls): Add omp_report_decl. * langhooks-def.h (LANG_HOOKS_OMP_REPORT_DECL): Define. (LANG_HOOKS_DECLS): Add it. * gimplify.c (omp_notice_variable): Call lang_hooks.decls.omp_report_decl. * trans-openmp.c (gfc_omp_predetermined_sharing): Don't return OMP_CLAUSE_DEFAULT_SHARED for artificial vars with GFC_DECL_SAVED_DESCRIPTOR set. (gfc_omp_report_decl): New function. * trans.h (gfc_omp_report_decl): New prototype. * f95-lang.c (LANG_HOOKS_OMP_REPORT_DECL): Redefine. * gfortran.dg/gomp/pr44536.f90: New test. * gfortran.dg/gomp/sharing-3.f90: Remove xfail. Jakub --- gcc/langhooks.h.jj 2010-05-21 11:46:31.000000000 +0200 +++ gcc/langhooks.h 2010-06-15 13:12:53.000000000 +0200 @@ -195,6 +195,10 @@ struct lang_hooks_for_decls predetermined, OMP_CLAUSE_DEFAULT_UNSPECIFIED otherwise. */ enum omp_clause_default_kind (*omp_predetermined_sharing) (tree); + /* Return decl that should be reported for DEFAULT(NONE) failure + diagnostics. Usually the DECL passed in. */ + tree (*omp_report_decl) (tree); + /* Return true if DECL's DECL_VALUE_EXPR (if any) should be disregarded in OpenMP construct, because it is going to be remapped during OpenMP lowering. SHARED is true if DECL --- gcc/langhooks-def.h.jj 2010-05-21 11:46:31.000000000 +0200 +++ gcc/langhooks-def.h 2010-06-15 13:11:42.000000000 +0200 @@ -202,6 +202,7 @@ extern tree lhd_make_node (enum tree_cod #define LANG_HOOKS_DECL_OK_FOR_SIBCALL lhd_decl_ok_for_sibcall #define LANG_HOOKS_OMP_PRIVATIZE_BY_REFERENCE hook_bool_const_tree_false #define LANG_HOOKS_OMP_PREDETERMINED_SHARING lhd_omp_predetermined_sharing +#define LANG_HOOKS_OMP_REPORT_DECL lhd_pass_through_t #define LANG_HOOKS_OMP_DISREGARD_VALUE_EXPR hook_bool_tree_bool_false #define LANG_HOOKS_OMP_PRIVATE_DEBUG_CLAUSE hook_bool_tree_bool_false #define LANG_HOOKS_OMP_PRIVATE_OUTER_REF hook_bool_tree_false @@ -224,6 +225,7 @@ extern tree lhd_make_node (enum tree_cod LANG_HOOKS_DECL_OK_FOR_SIBCALL, \ LANG_HOOKS_OMP_PRIVATIZE_BY_REFERENCE, \ LANG_HOOKS_OMP_PREDETERMINED_SHARING, \ + LANG_HOOKS_OMP_REPORT_DECL, \ LANG_HOOKS_OMP_DISREGARD_VALUE_EXPR, \ LANG_HOOKS_OMP_PRIVATE_DEBUG_CLAUSE, \ LANG_HOOKS_OMP_PRIVATE_OUTER_REF, \ --- gcc/gimplify.c.jj 2010-06-09 13:42:07.000000000 +0200 +++ gcc/gimplify.c 2010-06-15 13:18:57.000000000 +0200 @@ -5586,7 +5586,7 @@ omp_notice_variable (struct gimplify_omp { case OMP_CLAUSE_DEFAULT_NONE: error ("%qE not specified in enclosing parallel", - DECL_NAME (decl)); + DECL_NAME (lang_hooks.decls.omp_report_decl (decl))); if ((ctx->region_type & ORT_TASK) != 0) error_at (ctx->location, "enclosing task"); else --- gcc/fortran/trans-openmp.c.jj 2010-05-25 11:27:34.000000000 +0200 +++ gcc/fortran/trans-openmp.c 2010-06-15 13:41:24.000000000 +0200 @@ -75,7 +75,10 @@ gfc_omp_privatize_by_reference (const_tr enum omp_clause_default_kind gfc_omp_predetermined_sharing (tree decl) { - if (DECL_ARTIFICIAL (decl) && ! GFC_DECL_RESULT (decl)) + if (DECL_ARTIFICIAL (decl) + && ! GFC_DECL_RESULT (decl) + && ! (DECL_LANG_SPECIFIC (decl) + && GFC_DECL_SAVED_DESCRIPTOR (decl))) return OMP_CLAUSE_DEFAULT_SHARED; /* Cray pointees shouldn't be listed in any clauses and should be @@ -118,6 +121,19 @@ gfc_omp_predetermined_sharing (tree decl return OMP_CLAUSE_DEFAULT_UNSPECIFIED; } +/* Return decl that should be used when reporting DEFAULT(NONE) + diagnostics. */ + +tree +gfc_omp_report_decl (tree decl) +{ + if (DECL_ARTIFICIAL (decl) + && DECL_LANG_SPECIFIC (decl) + && GFC_DECL_SAVED_DESCRIPTOR (decl)) + return GFC_DECL_SAVED_DESCRIPTOR (decl); + + return decl; +} /* Return true if DECL in private clause needs OMP_CLAUSE_PRIVATE_OUTER_REF on the private clause. */ --- gcc/fortran/trans.h.jj 2010-06-09 13:42:02.000000000 +0200 +++ gcc/fortran/trans.h 2010-06-15 13:14:18.000000000 +0200 @@ -523,6 +523,7 @@ bool gfc_get_array_descr_info (const_tre /* In trans-openmp.c */ bool gfc_omp_privatize_by_reference (const_tree); enum omp_clause_default_kind gfc_omp_predetermined_sharing (tree); +tree gfc_omp_report_decl (tree); tree gfc_omp_clause_default_ctor (tree, tree, tree); tree gfc_omp_clause_copy_ctor (tree, tree, tree); tree gfc_omp_clause_assign_op (tree, tree, tree); --- gcc/fortran/f95-lang.c.jj 2010-06-12 10:38:13.000000000 +0200 +++ gcc/fortran/f95-lang.c 2010-06-15 13:13:58.000000000 +0200 @@ -111,6 +111,7 @@ static void gfc_init_ts (void); #undef LANG_HOOKS_INIT_TS #undef LANG_HOOKS_OMP_PRIVATIZE_BY_REFERENCE #undef LANG_HOOKS_OMP_PREDETERMINED_SHARING +#undef LANG_HOOKS_OMP_REPORT_DECL #undef LANG_HOOKS_OMP_CLAUSE_DEFAULT_CTOR #undef LANG_HOOKS_OMP_CLAUSE_COPY_CTOR #undef LANG_HOOKS_OMP_CLAUSE_ASSIGN_OP @@ -137,6 +138,7 @@ static void gfc_init_ts (void); #define LANG_HOOKS_INIT_TS gfc_init_ts #define LANG_HOOKS_OMP_PRIVATIZE_BY_REFERENCE gfc_omp_privatize_by_reference #define LANG_HOOKS_OMP_PREDETERMINED_SHARING gfc_omp_predetermined_sharing +#define LANG_HOOKS_OMP_REPORT_DECL gfc_omp_report_decl #define LANG_HOOKS_OMP_CLAUSE_DEFAULT_CTOR gfc_omp_clause_default_ctor #define LANG_HOOKS_OMP_CLAUSE_COPY_CTOR gfc_omp_clause_copy_ctor #define LANG_HOOKS_OMP_CLAUSE_ASSIGN_OP gfc_omp_clause_assign_op --- gcc/testsuite/gfortran.dg/gomp/pr44536.f90.jj 2010-06-15 13:48:34.000000000 +0200 +++ gcc/testsuite/gfortran.dg/gomp/pr44536.f90 2010-06-15 13:45:35.000000000 +0200 @@ -0,0 +1,10 @@ +! PR fortran/44536 +! { dg-do compile } +! { dg-options "-fopenmp" } + subroutine foo (a, i, j) + integer, dimension(:) :: a + integer :: i, j +!$omp parallel default(none) shared(i, j) ! { dg-error "enclosing parallel" } + j=a(i) ! { dg-error "not specified in" } +!$omp end parallel + end subroutine --- gcc/testsuite/gfortran.dg/gomp/sharing-3.f90.jj 2008-09-05 12:55:10.000000000 +0200 +++ gcc/testsuite/gfortran.dg/gomp/sharing-3.f90 2010-06-15 13:54:36.000000000 +0200 @@ -29,7 +29,7 @@ subroutine foo (vara, varb, varc, vard, !$omp master vara(1) = 1 ! { dg-error "not specified" } varb(1) = 1 ! Assumed-size is predetermined - varc(1) = 1 ! { dg-error "not specified" "" { xfail *-*-* } } + varc(1) = 1 ! { dg-error "not specified" } vard(1) = 1 ! { dg-error "not specified" } vare(1) = 1 ! { dg-error "not specified" } !$omp end master