From patchwork Fri Oct 3 14:08:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andi Kleen X-Patchwork-Id: 396244 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 1C7FF14012D for ; Sat, 4 Oct 2014 00:10:09 +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:from :to:cc:subject:date:message-id:in-reply-to:references; q=dns; s= default; b=CM/QHKm1RKIPbFP9jC7oseaTe8NTZzgkjwlyh2ZPo5EKTA8UrOa5I U2kcf6q52rAhEhWxZ4BJs2xMpeCwhqbVoJcr84RpDH8f8oyNh5N3KDWfMzxSWm1+ Zfz7JLXYjUA4kvRcz7Hs7sKqbmk6p4mEZQ1q34GE2eupdZb4shb4g8= 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:from :to:cc:subject:date:message-id:in-reply-to:references; s= default; bh=EhzsyKuftLVIuOhqJRQBtIz0aOg=; b=n/F6opcRoV/1PoWrUO9T i1cRcGbkn/Uq1J+dfDjdjfPahvXeKTksRURE5ZUQPVwD4py/Om5DIlg3BFhCcIQw RL0aWRaBzp8SzH+sqYK9uExtyD/DvXYxI5wTLzI8bJHgxjrP+9kqbTm7sEu3XJd2 DpiKbt4InrEvHXVLAyai3L0= Received: (qmail 31739 invoked by alias); 3 Oct 2014 14:09:51 -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 31712 invoked by uid 89); 3 Oct 2014 14:09:50 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: one.firstfloor.org Received: from one.firstfloor.org (HELO one.firstfloor.org) (193.170.194.197) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Fri, 03 Oct 2014 14:09:49 +0000 Received: from basil.firstfloor.org (184-100-254-193.ptld.qwest.net [184.100.254.193]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by one.firstfloor.org (Postfix) with ESMTPSA id 94D47869AB; Fri, 3 Oct 2014 16:09:44 +0200 (CEST) Received: by basil.firstfloor.org (Postfix, from userid 1000) id 9793FA1FC6; Fri, 3 Oct 2014 07:09:02 -0700 (PDT) From: Andi Kleen To: gcc-patches@gcc.gnu.org Cc: Andi Kleen Subject: [PATCH 2/2] Add illegal cilk checks to C++ front. Date: Fri, 3 Oct 2014 07:08:58 -0700 Message-Id: <1412345338-18397-3-git-send-email-andi@firstfloor.org> In-Reply-To: <1412345338-18397-2-git-send-email-andi@firstfloor.org> References: <1412345338-18397-1-git-send-email-andi@firstfloor.org> <1412345338-18397-2-git-send-email-andi@firstfloor.org> From: Andi Kleen Add calls for several illegal Cilk cases to the C++ frontend. C++ usually doesn't ICE unlike C on illegal cilk, but it's better to match C in what is allowed and what is not. if (_Cilk_spawn ...) is still not errored, but at least it doesn't ICE. gcc/cp/: 2014-09-30 Andi Kleen * semantics.c (finish_goto_stmt): Call check_no_cilk. (finish_while_stmt_cond): Dito. (finish_do_stmt): Dito. (finish_for_cond): Dito. (finish_switch_cond): Dito. --- gcc/cp/semantics.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 7569826..e7ff223 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -621,6 +621,10 @@ finish_goto_stmt (tree destination) TREE_USED (destination) = 1; else { + if (check_no_cilk (destination, + "Cilk array notation cannot be used as a computed goto expression", + "%<_Cilk_spawn%> statement cannot be used as a computed goto expression")) + destination = error_mark_node; destination = mark_rvalue_use (destination); if (!processing_template_decl) { @@ -792,6 +796,10 @@ begin_while_stmt (void) void finish_while_stmt_cond (tree cond, tree while_stmt, bool ivdep) { + if (check_no_cilk (cond, + "Cilk array notation cannot be used as a condition for while statement", + "%<_Cilk_spawn%> statement cannot be used as a condition for while statement")) + cond = error_mark_node; cond = maybe_convert_cond (cond); finish_cond (&WHILE_COND (while_stmt), cond); begin_maybe_infinite_loop (cond); @@ -847,6 +855,10 @@ finish_do_body (tree do_stmt) void finish_do_stmt (tree cond, tree do_stmt, bool ivdep) { + if (check_no_cilk (cond, + "Cilk array notation cannot be used as a condition for a do-while statement", + "%<_Cilk_spawn%> statement cannot be used as a condition for a do-while statement")) + cond = error_mark_node; cond = maybe_convert_cond (cond); end_maybe_infinite_loop (cond); if (ivdep && cond != error_mark_node) @@ -956,6 +968,10 @@ finish_for_init_stmt (tree for_stmt) void finish_for_cond (tree cond, tree for_stmt, bool ivdep) { + if (check_no_cilk (cond, + "Cilk array notation cannot be used in a condition for a for-loop", + "%<_Cilk_spawn%> statement cannot be used in a condition for a for-loop")) + cond = error_mark_node; cond = maybe_convert_cond (cond); finish_cond (&FOR_COND (for_stmt), cond); begin_maybe_infinite_loop (cond); @@ -1118,6 +1134,12 @@ void finish_switch_cond (tree cond, tree switch_stmt) { tree orig_type = NULL; + + if (check_no_cilk (cond, + "Cilk array notation cannot be used as a condition for switch statement", + "%<_Cilk_spawn%> statement cannot be used as a condition for switch statement")) + cond = error_mark_node; + if (!processing_template_decl) { /* Convert the condition to an integer or enumeration type. */