From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 36669 invoked by alias); 2 Nov 2015 20:08:58 -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 36646 invoked by uid 89); 2 Nov 2015 20:08:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.6 required=5.0 tests=AWL,BAYES_00,SPF_PASS,T_RP_MATCHES_RCVD,UNWANTED_LANGUAGE_BODY autolearn=ham version=3.3.2 X-HELO: mga03.intel.com Received: from mga03.intel.com (HELO mga03.intel.com) (134.134.136.65) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 02 Nov 2015 20:08:55 +0000 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP; 02 Nov 2015 12:08:53 -0800 X-ExtLoop1: 1 Received: from irsmsx105.ger.corp.intel.com ([163.33.3.28]) by fmsmga001.fm.intel.com with ESMTP; 02 Nov 2015 12:08:49 -0800 Received: from irsmsx101.ger.corp.intel.com ([169.254.1.33]) by irsmsx105.ger.corp.intel.com ([169.254.7.75]) with mapi id 14.03.0248.002; Mon, 2 Nov 2015 20:08:48 +0000 From: "Zamyatin, Igor" To: "GCC Patches (gcc-patches@gcc.gnu.org)" CC: "Jeff Law (law@redhat.com)" , "Jakub Jelinek (jakub@redhat.com)" Subject: [PR68001, CilkPlus] Fix for PR68001 Date: Mon, 02 Nov 2015 20:08:00 -0000 Message-ID: <0EFAB2BDD0F67E4FB6CCC8B9F87D756973814270@IRSMSX101.ger.corp.intel.com> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-IsSubscribed: yes X-SW-Source: 2015-11/txt/msg00118.txt.bz2 Hi! This patch attempts to enhance error diagnostic in case of CilkPlus and fix= es PR68001. Bootstrapped and regtested for x86_64. Is it ok for trunk? Thanks, Igor ChangeLog: c-family 2015-11-02 Igor Zamyatin PR c++/68001 * c-gimplify.c (c_gimplify_expr): Stop the process if see an error. * cilk.c (recognize_spawn): Determine location in a more precise way. cp 2015-11-02 Igor Zamyatin PR c++/68001 * cp-gimplify.c (cp_gimplify_expr): Stop the process if see an error. testsuite 2015-11-02 Igor Zamyatin PR c++/68001 * g++.dg/cilk-plus/CK/pr68001.cc: New test. diff --git a/gcc/c-family/c-gimplify.c b/gcc/c-family/c-gimplify.c index 92987b5..5b173d5 100644 --- a/gcc/c-family/c-gimplify.c +++ b/gcc/c-family/c-gimplify.c @@ -283,15 +283,16 @@ c_gimplify_expr (tree *expr_p, gimple_seq *pre_p ATTR= IBUTE_UNUSED, =20 case CILK_SPAWN_STMT: gcc_assert - (fn_contains_cilk_spawn_p (cfun) - && cilk_detect_spawn_and_unwrap (expr_p)); + (fn_contains_cilk_spawn_p (cfun) + && cilk_detect_spawn_and_unwrap (expr_p)); =20 - /* If errors are seen, then just process it as a CALL_EXPR. */ if (!seen_error ()) { cilk_gimplify_call_params_in_spawned_fn (expr_p, pre_p, post_p); return (enum gimplify_status) gimplify_cilk_spawn (expr_p); } + return GS_ERROR; + case MODIFY_EXPR: case INIT_EXPR: case CALL_EXPR: diff --git a/gcc/c-family/cilk.c b/gcc/c-family/cilk.c index 1c316a4..77cb6e4 100644 --- a/gcc/c-family/cilk.c +++ b/gcc/c-family/cilk.c @@ -82,6 +82,8 @@ struct wrapper_data tree block; }; =20 +static tree +contains_cilk_spawn_stmt_walker (tree *tp, int *, void *); static void extract_free_variables (tree, struct wrapper_data *, enum add_variable_type); static HOST_WIDE_INT cilk_wrapper_count; @@ -241,7 +243,19 @@ recognize_spawn (tree exp, tree *exp0) } /* _Cilk_spawn can't be wrapped in expression such as PLUS_EXPR. */ else if (contains_cilk_spawn_stmt (exp)) - error_at (EXPR_LOCATION (exp), "invalid use of %<_Cilk_spawn%>"); + { + location_t loc =3D EXPR_LOCATION (exp); + if (loc =3D=3D UNKNOWN_LOCATION) + { + tree stmt =3D walk_tree (&exp, + contains_cilk_spawn_stmt_walker, + NULL, + NULL); + gcc_assert (stmt !=3D NULL_TREE); + loc =3D EXPR_LOCATION (stmt); + } + error_at (loc, "invalid use of %<_Cilk_spawn%>"); + } return spawn_found; } =20 diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c index e37cbc7..6b444d6 100644 --- a/gcc/cp/cp-gimplify.c +++ b/gcc/cp/cp-gimplify.c @@ -625,6 +625,9 @@ cp_gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimp= le_seq *post_p) cilk_cp_gimplify_call_params_in_spawned_fn (expr_p, pre_p, post_p); return (enum gimplify_status) gimplify_cilk_spawn (expr_p); } + else if (seen_error ()) + return GS_ERROR; + cp_gimplify_init_expr (expr_p); if (TREE_CODE (*expr_p) !=3D INIT_EXPR) return GS_OK; @@ -733,16 +736,17 @@ cp_gimplify_expr (tree *expr_p, gimple_seq *pre_p, gi= mple_seq *post_p) break; =20 case CILK_SPAWN_STMT: - gcc_assert=20 - (fn_contains_cilk_spawn_p (cfun)=20 - && cilk_detect_spawn_and_unwrap (expr_p)); + gcc_assert + (fn_contains_cilk_spawn_p (cfun) + && cilk_detect_spawn_and_unwrap (expr_p)); =20 - /* If errors are seen, then just process it as a CALL_EXPR. */ if (!seen_error ()) { cilk_cp_gimplify_call_params_in_spawned_fn (expr_p, pre_p, post_p); return (enum gimplify_status) gimplify_cilk_spawn (expr_p); } + return GS_ERROR; + case CALL_EXPR: if (fn_contains_cilk_spawn_p (cfun) && cilk_detect_spawn_and_unwrap (expr_p) diff --git a/gcc/testsuite/g++.dg/cilk-plus/CK/pr68001.cc b/gcc/testsuite/g= ++.dg/cilk-plus/CK/pr68001.cc new file mode 100644 index 0000000..6137c07 --- /dev/null +++ b/gcc/testsuite/g++.dg/cilk-plus/CK/pr68001.cc @@ -0,0 +1,19 @@ +/* PR middle-end/68001 */ +/* { dg-do compile } */ +/* { dg-options "-fcilkplus" } */ + +#include +#include + +std::vector f() { + std::vector v; + return v; +} + +int main() +{ + std::vector x =3D cilk_spawn f(); /* { dg-error "invalid use of"= } */ + std::vector y =3D f(); + cilk_sync; + return 0; +}