From patchwork Thu Feb 9 14:08:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 726132 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 3vK0Lf21RCz9s7R for ; Fri, 10 Feb 2017 01:09:14 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="AQwzMnc5"; 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:date :from:to:subject:message-id:reply-to:mime-version:content-type; q=dns; s=default; b=qlcXFxjZs7ct6JhLE1IcSn0RgBw1KDCTMwkbHAjz2+3 kIQTf/TBfF0ZOq8lFW0iJwQJUoFL+6k0uuIqRTOBYX9LaLSg8skF62SW3xU2bAdK eAYra1Ch20j4Nej8wqAda/CiXa+VSdxjLqKRJWdThDfgR7qsi/VEfstmx39CQblE = 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:subject:message-id:reply-to:mime-version:content-type; s=default; bh=uGe54Nsh0pmPsjoXzwyEXhYmxM8=; b=AQwzMnc5fDDfCgOJ+ mo+jA+hsb/kqBAe8aheW3RPzxEePwDLrAti/xhSyCRTF3EBKogTmWLn1CQeizg6Q Wc0LJOfK5AyG1zqAHSKHpdjJKf1VTO5eo3CZvzanufh5e5ygpRnZbgQV7kiScYQS kC9I4ur/K63kWBh1DnBzGtc6TQ= Received: (qmail 98297 invoked by alias); 9 Feb 2017 14:09:05 -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 98282 invoked by uid 89); 9 Feb 2017 14:09:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=*pc X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 09 Feb 2017 14:09:02 +0000 Received: from smtp.corp.redhat.com (int-mx16.intmail.prod.int.phx2.redhat.com [10.5.11.28]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 32A1180489 for ; Thu, 9 Feb 2017 14:09:02 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-116-76.ams2.redhat.com [10.36.116.76]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C946E74A1A for ; Thu, 9 Feb 2017 14:09:01 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id v19E8wEp031229 for ; Thu, 9 Feb 2017 15:08:58 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id v19E8wjT031228 for gcc-patches@gcc.gnu.org; Thu, 9 Feb 2017 15:08:58 +0100 Date: Thu, 9 Feb 2017 15:08:58 +0100 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Subject: [committed] Fix #pragma omp {target, ordered} error-recovery (PR c++/79429) Message-ID: <20170209140858.GJ1849@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.7.1 (2016-10-04) X-IsSubscribed: yes Hi! This patch fixes error-recovery on the following testcases. {push,pop}_omp_privatization_clauses should not be used outside of functions, fixed by diagnosing it/punting it before we call those. Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk. 2017-02-09 Jakub Jelinek PR c++/79429 * parser.c (cp_parser_omp_ordered): Don't check for non-pragma_stmt non-pragma_compound context here. (cp_parser_omp_target): Likewise. (cp_parser_pragma): Don't call push_omp_privatization_clauses and parsing for ordered and target omp pragmas in non-pragma_stmt non-pragma_compound contexts. * c-c++-common/gomp/pr79429.c: New test. * g++.dg/gomp/pr79429.C: New test. Jakub --- gcc/cp/parser.c.jj 2017-02-09 10:07:38.000000000 +0100 +++ gcc/cp/parser.c 2017-02-09 10:53:54.649952780 +0100 @@ -34923,13 +34923,6 @@ cp_parser_omp_ordered (cp_parser *parser { location_t loc = pragma_tok->location; - if (context != pragma_stmt && context != pragma_compound) - { - cp_parser_error (parser, "expected declaration specifiers"); - cp_parser_skip_to_pragma_eol (parser, pragma_tok); - return false; - } - if (cp_lexer_next_token_is (parser->lexer, CPP_NAME)) { tree id = cp_lexer_peek_token (parser->lexer)->u.value; @@ -35835,13 +35828,6 @@ cp_parser_omp_target (cp_parser *parser, { tree *pc = NULL, stmt; - if (context != pragma_stmt && context != pragma_compound) - { - cp_parser_error (parser, "expected declaration specifiers"); - cp_parser_skip_to_pragma_eol (parser, pragma_tok); - return false; - } - if (cp_lexer_next_token_is (parser->lexer, CPP_NAME)) { tree id = cp_lexer_peek_token (parser->lexer)->u.value; @@ -38272,12 +38258,16 @@ cp_parser_pragma (cp_parser *parser, enu return true; case PRAGMA_OMP_ORDERED: + if (context != pragma_stmt && context != pragma_compound) + goto bad_stmt; stmt = push_omp_privatization_clauses (false); ret = cp_parser_omp_ordered (parser, pragma_tok, context, if_p); pop_omp_privatization_clauses (stmt); return ret; case PRAGMA_OMP_TARGET: + if (context != pragma_stmt && context != pragma_compound) + goto bad_stmt; stmt = push_omp_privatization_clauses (false); ret = cp_parser_omp_target (parser, pragma_tok, context, if_p); pop_omp_privatization_clauses (stmt); --- gcc/testsuite/c-c++-common/gomp/pr79429.c.jj 2017-02-09 10:57:01.071495848 +0100 +++ gcc/testsuite/c-c++-common/gomp/pr79429.c 2017-02-09 10:56:22.000000000 +0100 @@ -0,0 +1,3 @@ +/* PR c++/79429 */ + +#pragma omp target /* { dg-error "expected declaration specifiers" } */ --- gcc/testsuite/g++.dg/gomp/pr79429.C.jj 2017-02-09 10:57:22.552212847 +0100 +++ gcc/testsuite/g++.dg/gomp/pr79429.C 2017-02-09 10:57:32.363083593 +0100 @@ -0,0 +1,3 @@ +// PR c++/79429 + +#pragma omp ordered // { dg-error "expected declaration specifiers" }