From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 59263 invoked by alias); 11 Oct 2019 14:17:15 -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 59255 invoked by uid 89); 11 Oct 2019 14:17:14 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.7 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS autolearn=ham version=3.3.1 spammy= 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; Fri, 11 Oct 2019 14:17:13 +0000 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9377A10C092E; Fri, 11 Oct 2019 14:17:12 +0000 (UTC) Received: from redhat.com (ovpn-121-75.rdu2.redhat.com [10.10.121.75]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2AEEF5D9CA; Fri, 11 Oct 2019 14:17:11 +0000 (UTC) Date: Fri, 11 Oct 2019 14:17:00 -0000 From: Marek Polacek To: Matthias Kretz Cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH] Fix parser to recognize operator?: Message-ID: <20191011141709.GN2949@redhat.com> References: <3763881.t63Sp36aLF@depc447> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <3763881.t63Sp36aLF@depc447> User-Agent: Mutt/1.12.1 (2019-06-15) X-SW-Source: 2019-10/txt/msg00828.txt.bz2 On Fri, Oct 11, 2019 at 04:06:43PM +0200, Matthias Kretz wrote: > This is a minor bugfix for improved error reporting. Overloading ?: is just as > disallowed as it is without this change. Thanks. Can you provide a testcase that shows why this change makes sense? That testcase then should be part of the patch submission. > 2019-10-11 Matthias Kretz > > * gcc/cp/parser.c (cp_parser_operator): Parse operator?: as an > attempt to overload the conditional operator. Then > grok_op_properties can print its useful "ISO C++ prohibits > overloading operator ?:" message instead of the cryptic error > message about a missing type-specifier before '?' token. > > diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c > index 3ee8da7db94..73385cb3dcb 100644 > --- a/gcc/cp/parser.c > +++ b/gcc/cp/parser.c > @@ -15502,6 +15502,15 @@ cp_parser_operator (cp_parser* parser, location_t > start_loc) > op = COMPONENT_REF; > break; > > + case CPP_QUERY: > + op = COND_EXPR; > + /* Consume the `?'. */ > + cp_lexer_consume_token (parser->lexer); > + /* Look for the matching `:'. */ > + cp_parser_require (parser, CPP_COLON, RT_COLON); > + consumed = true; > + break; > + > case CPP_OPEN_PAREN: > { > /* Consume the `('. */ -- Marek Polacek • Red Hat, Inc. • 300 A St, Boston, MA