From patchwork Wed Jul 3 14:15:53 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 256653 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 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 35C692C0306 for ; Thu, 4 Jul 2013 00:16:07 +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:date :from:to:cc:subject:message-id:reply-to:mime-version :content-type; q=dns; s=default; b=p0ShlFOQ0+FBKp36qRcAoowWeSbti m1hkq/HugdDW3A3b80roMopiwCLdSM51RULn/8a2Kr6xKNyGxU2VzbOBJUo4+YEU /rdXt9CuiKFU1/eZ1bCgzTdK0A/M3ZoIR68WWaZ4fq9kYcOGIB2ekyxthKc5LV5Z 9ho2GcHAaBecmU= 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=kyoiqVgjvEgYZJ1vqCe23CQquas=; b=A8K HT6k2qlO1Ivf+Kdb+j+4NkpOXZj88gOFjLRfDObO6DAFDA+Z+E4rj6pAz/WlJufh J5alhz8jqsp79SJC+F0sNmWPLnOCnsCodzOFNKiSIp5u5dvWHirm/IUg7Kmo2ia/ dIm0SBYZ9rqwkU/VPXXDggy0/G4jn4BQSCJf+weY= Received: (qmail 32138 invoked by alias); 3 Jul 2013 14:16:01 -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 32119 invoked by uid 89); 3 Jul 2013 14:16:00 -0000 X-Spam-SWARE-Status: No, score=-6.3 required=5.0 tests=AWL, BAYES_00, RCVD_IN_HOSTKARMA_W, RCVD_IN_HOSTKARMA_WL, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.1 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Wed, 03 Jul 2013 14:15:59 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r63EFu5q007285 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 3 Jul 2013 10:15:57 -0400 Received: from zalov.cz (vpn1-7-109.ams2.redhat.com [10.36.7.109]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r63EFsF1023862 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 3 Jul 2013 10:15:56 -0400 Received: from zalov.cz (localhost [127.0.0.1]) by zalov.cz (8.14.5/8.14.5) with ESMTP id r63EFsVn032578; Wed, 3 Jul 2013 16:15:54 +0200 Received: (from jakub@localhost) by zalov.cz (8.14.5/8.14.5/Submit) id r63EFrUX032577; Wed, 3 Jul 2013 16:15:53 +0200 Date: Wed, 3 Jul 2013 16:15:53 +0200 From: Jakub Jelinek To: Jason Merrill Cc: gcc-patches@gcc.gnu.org Subject: [C++ PATCH] Fix up static_cast/reinterpret_cast parsing in template argument (PR c++/57771) Message-ID: <20130703141553.GO2336@tucnak.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Hi! When parsing static_cast (expression) part inside of template argument, greater_than_is_operator_p isn't temporarily set and thus the parser considers >> in C++11 there as end of the the template argument, despite this appearing before terminating ). Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk/4.8? 2013-07-01 Jakub Jelinek PR c++/57771 * parser.c (cp_parser_postfix_expression) Temporarily set parser->greater_than_is_operator_p for cp_parser_expression and restore from saved value afterwards. * g++.dg/template/arg9.C: New test. Jakub --- gcc/cp/parser.c.jj 2013-07-01 22:43:42.000000000 +0200 +++ gcc/cp/parser.c 2013-07-01 22:47:14.220634900 +0200 @@ -5576,11 +5576,18 @@ cp_parser_postfix_expression (cp_parser /* Restore the old message. */ parser->type_definition_forbidden_message = saved_message; + bool saved_greater_than_is_operator_p + = parser->greater_than_is_operator_p; + parser->greater_than_is_operator_p = true; + /* And the expression which is being cast. */ cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN); expression = cp_parser_expression (parser, /*cast_p=*/true, & idk); cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN); + parser->greater_than_is_operator_p + = saved_greater_than_is_operator_p; + /* Only type conversions to integral or enumeration types can be used in constant-expressions. */ if (!cast_valid_in_integral_constant_expression_p (type) --- gcc/testsuite/g++.dg/template/arg9.C.jj 2013-07-01 22:52:22.780699584 +0200 +++ gcc/testsuite/g++.dg/template/arg9.C 2013-07-01 22:51:22.000000000 +0200 @@ -0,0 +1,8 @@ +// PR c++/57771 +// { dg-do compile } + +template +struct S {}; + +S (4>>2)> s1; +S (4>>2)> s2;