From patchwork Tue Feb 4 12:43:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 316579 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 68EFC2C0091 for ; Tue, 4 Feb 2014 23:43:14 +1100 (EST) 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:cc:subject:message-id:reply-to:mime-version :content-type; q=dns; s=default; b=HcFc4fkwpdq0egX/w4gJyPKcjGr+/ 0zHKcXyhq/83TvGkj37efgSnXt5/AH9RxZG46joHncfjbVdy0YQZ2XvxJ65cZIbI mZnSbTrQhN+jcJil1h+R3RSkwICXNMFtJudIegCcZYHFjICLpDCPQTaNa96KIifU ulvtlw+9yi0+n0= 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:cc:subject:message-id:reply-to:mime-version :content-type; s=default; bh=zGo39XU/YAteReXhDYgxdcFWK1U=; b=Gg6 4EkPHBr75Ej8hJ1Ere+dTdgREGSwq01VEMVF5zHdLd9LQH7gXNXc9V708zACwROB 3iKF0xCBaME6OamKsfry67FB7O83haPAZHqsRmNNnAfoS3fJziIsgSIEaLU9ojeM jS5qQDMfGwDGEURlsHseUpO4jE8UTcPypF0MHFQY= Received: (qmail 9590 invoked by alias); 4 Feb 2014 12:43:07 -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 9580 invoked by uid 89); 4 Feb 2014 12:43:06 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.9 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 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; Tue, 04 Feb 2014 12:43:05 +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.14.4/8.14.4) with ESMTP id s14Ch4me014769 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 4 Feb 2014 07:43:04 -0500 Received: from tucnak.zalov.cz (vpn1-4-26.ams2.redhat.com [10.36.4.26]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s14Ch2ch004746 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 4 Feb 2014 07:43:03 -0500 Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.14.7/8.14.7) with ESMTP id s14Ch1io002568; Tue, 4 Feb 2014 13:43:02 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.14.7/8.14.7/Submit) id s14Ch1Iw002567; Tue, 4 Feb 2014 13:43:01 +0100 Date: Tue, 4 Feb 2014 13:43:01 +0100 From: Jakub Jelinek To: Jason Merrill Cc: gcc-patches@gcc.gnu.org Subject: [C++ PATCH] Restore declarator_obstack in cp_parser_omp_declare_reduction (PR c++/58703) Message-ID: <20140204124301.GK12671@tucnak.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes Hi! Apparently at least on invalid #pragma omp declare reduction, when parsing the type-ids, the parser may allocate some declarators of the declarator_obstack, which results in ICE at the end of translation unit when declarator_obstack is not in the initial empty state. Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2014-02-04 Jakub Jelinek PR c++/58703 * parser.c (cp_parser_omp_declare_reduction): Save and free declarator_obstack. * c-c++-common/gomp/pr58703.c: New test. Jakub --- gcc/cp/parser.c.jj 2014-02-03 08:53:11.000000000 +0100 +++ gcc/cp/parser.c 2014-02-03 14:00:58.569308322 +0100 @@ -30623,6 +30623,10 @@ cp_parser_omp_declare_reduction (cp_pars cp_token *first_token; cp_token_cache *cp; int errs; + void *p; + + /* Get the high-water mark for the DECLARATOR_OBSTACK. */ + p = obstack_alloc (&declarator_obstack, 0); if (!cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN)) goto fail; @@ -30731,6 +30735,9 @@ cp_parser_omp_declare_reduction (cp_pars { fail: cp_parser_skip_to_pragma_eol (parser, pragma_tok); + + /* Free any declarators allocated. */ + obstack_free (&declarator_obstack, p); return; } @@ -30835,6 +30842,9 @@ cp_parser_omp_declare_reduction (cp_pars } cp_parser_require_pragma_eol (parser, pragma_tok); + + /* Free any declarators allocated. */ + obstack_free (&declarator_obstack, p); } /* OpenMP 4.0 --- gcc/testsuite/c-c++-common/gomp/pr58703.c.jj 2014-02-03 14:02:56.735693978 +0100 +++ gcc/testsuite/c-c++-common/gomp/pr58703.c 2014-02-03 14:02:37.000000000 +0100 @@ -0,0 +1,6 @@ +/* PR c++/58703 */ +/* { dg-do compile } */ +/* { dg-options "-fopenmp" } */ + +#pragma omp declare reduction (+ : char[] : omp_out += omp_in) /* { dg-error "function or array type" } */ +#pragma omp declare reduction (+ : char() : omp_out += omp_in) /* { dg-error "function or array type" } */