From patchwork Tue Oct 31 18:28:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 832687 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-465638-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="U43ya0XQ"; dkim-atps=neutral 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 3yRKcH42WBz9sPm for ; Wed, 1 Nov 2017 05:28:47 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:from:to:references:message-id:date:mime-version :in-reply-to:content-type; q=dns; s=default; b=ncBEFwJCEWjopuZXv NmtF18VoCn243Mh4psFeVTcFUdkIFNLgvrSXsay3jpm5t6v2799o3LF8+oRwCPZc 3S2ksM0Fz2umerRsXc1mG/+tWx0O6F84O/TFJ7nGWAcCTQo/W889wLVK7habG0Ck Jz7Di3HT9pvc5VGs3WmZO6GgN4= 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 :subject:from:to:references:message-id:date:mime-version :in-reply-to:content-type; s=default; bh=pvHZWwExuWLV4LFAuDSyaDm tSf0=; b=U43ya0XQ/v3nX8RiVyTk2KtV48RJISFnawSJl3DIv7Lp+fZ60Sbi1oT 9Uwv1i3aV3S40xMLda5cvTyLNIQxIvgdRU0Ec2qwy9KjZxGX2ijTWBe0HJuqmIa3 Wy1WrKtYsBvjQRVV83b0SHlp/dUom9L2JJRDSf0EgSoxOSutSiO4= Received: (qmail 8903 invoked by alias); 31 Oct 2017 18:28:39 -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 8887 invoked by uid 89); 31 Oct 2017 18:28:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.6 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-yw0-f174.google.com Received: from mail-yw0-f174.google.com (HELO mail-yw0-f174.google.com) (209.85.161.174) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 31 Oct 2017 18:28:36 +0000 Received: by mail-yw0-f174.google.com with SMTP id z195so15564189ywz.6 for ; Tue, 31 Oct 2017 11:28:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:references:message-id :date:user-agent:mime-version:in-reply-to:content-language; bh=7vmY+svSRjoNdvMLcO2hHNGExQK7qnMCdaW0eVrgJo8=; b=UqzEDYlwuU0TtoLOOK6Or67jHcCUhAl800jCkt3i1MUUbuD8/6KX8Wo012k9zB+3Su 40rqaBaZp0rPAb2dsUOTDNHEKVkYjQjAu44FWmS6uwdke+TceMrt6M66JWQTNjplXoRD juj2JkTD6GHpiI2I3Ry/oWZAll03VglkzUtbKqqCwpbBckLatK8Q9t58F8fjfvOj15TW VpdJAFkC0uBnF20uITDxv98RqOtdghdDCmtAw1xllKJYTBBxK4bnuIaPTqeh5Xi2xkBu yH8eR46IRqRqVS7vNmGU1Ynn+7A+UmXqfp8jyAX5wmcOgxehwbUJtQPP5MfG2aHIONqN 1p7A== X-Gm-Message-State: AMCzsaVBCLWhAsGvZRK0LKqh1vaK6bwNOSFxTLLJw60KW/EoJH3fwAFS azvgM6lOVwrD3RRacBNryPI= X-Google-Smtp-Source: ABhQp+QeuEfam/UwC9lPDLtBtr7UXH7iHB/1bxZJKK7uNmWL3CLJ761em/An/4V9uCKnqC4Vfc6mfA== X-Received: by 10.37.7.193 with SMTP id 184mr1887780ybh.413.1509474514947; Tue, 31 Oct 2017 11:28:34 -0700 (PDT) Received: from ?IPv6:2620:10d:c0a3:20fb:7500:e7fb:4a6f:2254? ([2620:10d:c091:200::3:68fe]) by smtp.googlemail.com with ESMTPSA id w5sm879372ywl.6.2017.10.31.11.28.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 31 Oct 2017 11:28:34 -0700 (PDT) Subject: [C++ PATCH] overloaded operator fns [4/N] From: Nathan Sidwell To: GCC Patches References: <40b48778-5335-2398-3dd5-e59f68b8f052@acm.org> Message-ID: <006c8467-dde6-1605-243c-f8d033ab4e49@acm.org> Date: Tue, 31 Oct 2017 14:28:33 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: The overloaded operator table conflates a couple of things -- both mangling and special names. Entries just for mangling do not need a special name. This sets them to NULL and no associated identifier is created. init_operators created a bunch of pseudo entries, ostensibly 'because errors', with a comment that we shouldn't be generating them. Turns out we don't appear to be using them, so also nuked. nathan 2017-10-31 Nathan Sidwell * lex.c (init_operators): Allow NULL operator name. Don't add special cases. * operators.def: Use NULL for mangling only operators. Move to after regular operators but move assignment operators last. Index: lex.c =================================================================== --- lex.c (revision 254271) +++ lex.c (working copy) @@ -143,48 +143,14 @@ init_operators (void) oni->name = NAME; \ oni->mangled_name = MANGLING; \ oni->flags = FLAGS; \ - identifier = set_operator_ident (oni); \ - \ - if (KIND != cik_simple_op || !IDENTIFIER_ANY_OP_P (identifier)) \ - set_identifier_kind (identifier, KIND); + if (NAME) { \ + identifier = set_operator_ident (oni); \ + if (KIND != cik_simple_op || !IDENTIFIER_ANY_OP_P (identifier)) \ + set_identifier_kind (identifier, KIND); \ + } #include "operators.def" #undef DEF_OPERATOR - - operator_name_info[(int) TYPE_EXPR] = operator_name_info[(int) CAST_EXPR]; - operator_name_info[(int) ERROR_MARK].identifier - = get_identifier (""); - - /* Handle some special cases. These operators are not defined in - the language, but can be produced internally. We may need them - for error-reporting. (Eventually, we should ensure that this - does not happen. Error messages involving these operators will - be confusing to users.) */ - - operator_name_info [(int) INIT_EXPR].name - = operator_name_info [(int) MODIFY_EXPR].name; - - operator_name_info [(int) EXACT_DIV_EXPR].name = "(ceiling /)"; - operator_name_info [(int) CEIL_DIV_EXPR].name = "(ceiling /)"; - operator_name_info [(int) FLOOR_DIV_EXPR].name = "(floor /)"; - operator_name_info [(int) ROUND_DIV_EXPR].name = "(round /)"; - operator_name_info [(int) CEIL_MOD_EXPR].name = "(ceiling %)"; - operator_name_info [(int) FLOOR_MOD_EXPR].name = "(floor %)"; - operator_name_info [(int) ROUND_MOD_EXPR].name = "(round %)"; - - operator_name_info [(int) ABS_EXPR].name = "abs"; - operator_name_info [(int) TRUTH_AND_EXPR].name = "strict &&"; - operator_name_info [(int) TRUTH_OR_EXPR].name = "strict ||"; - operator_name_info [(int) RANGE_EXPR].name = "..."; - operator_name_info [(int) UNARY_PLUS_EXPR].name = "+"; - - assignment_operator_name_info [(int) EXACT_DIV_EXPR].name = "(exact /=)"; - assignment_operator_name_info [(int) CEIL_DIV_EXPR].name = "(ceiling /=)"; - assignment_operator_name_info [(int) FLOOR_DIV_EXPR].name = "(floor /=)"; - assignment_operator_name_info [(int) ROUND_DIV_EXPR].name = "(round /=)"; - assignment_operator_name_info [(int) CEIL_MOD_EXPR].name = "(ceiling %=)"; - assignment_operator_name_info [(int) FLOOR_MOD_EXPR].name = "(floor %=)"; - assignment_operator_name_info [(int) ROUND_MOD_EXPR].name = "(round %=)"; } /* Initialize the reserved words. */ Index: operators.def =================================================================== --- operators.def (revision 254271) +++ operators.def (working copy) @@ -100,13 +100,6 @@ DEF_SIMPLE_OPERATOR ("alignof", ALIGNOF_ DEF_SIMPLE_OPERATOR ("__imag__", IMAGPART_EXPR, "v18__imag__", OVL_OP_FLAG_UNARY) DEF_SIMPLE_OPERATOR ("__real__", REALPART_EXPR, "v18__real__", OVL_OP_FLAG_UNARY) -/* The cast operators. */ -DEF_SIMPLE_OPERATOR ("", CAST_EXPR, "cv", OVL_OP_FLAG_UNARY) -DEF_SIMPLE_OPERATOR ("dynamic_cast", DYNAMIC_CAST_EXPR, "dc", OVL_OP_FLAG_UNARY) -DEF_SIMPLE_OPERATOR ("reinterpret_cast", REINTERPRET_CAST_EXPR, "rc", OVL_OP_FLAG_UNARY) -DEF_SIMPLE_OPERATOR ("const_cast", CONST_CAST_EXPR, "cc", OVL_OP_FLAG_UNARY) -DEF_SIMPLE_OPERATOR ("static_cast", STATIC_CAST_EXPR, "sc", OVL_OP_FLAG_UNARY) - /* Binary operators. */ DEF_SIMPLE_OPERATOR ("+", PLUS_EXPR, "pl", OVL_OP_FLAG_BINARY) DEF_SIMPLE_OPERATOR ("-", MINUS_EXPR, "mi", OVL_OP_FLAG_BINARY) @@ -133,8 +126,23 @@ DEF_SIMPLE_OPERATOR ("->", COMPONENT_REF DEF_SIMPLE_OPERATOR ("[]", ARRAY_REF, "ix", OVL_OP_FLAG_BINARY) DEF_SIMPLE_OPERATOR ("++", POSTINCREMENT_EXPR, "pp", OVL_OP_FLAG_BINARY) DEF_SIMPLE_OPERATOR ("--", POSTDECREMENT_EXPR, "mm", OVL_OP_FLAG_BINARY) -/* This one is needed for mangling. */ -DEF_SIMPLE_OPERATOR ("::", SCOPE_REF, "sr", OVL_OP_FLAG_BINARY) + +/* Miscellaneous. */ +DEF_SIMPLE_OPERATOR ("?:", COND_EXPR, "qu", OVL_OP_FLAG_NONE) +DEF_SIMPLE_OPERATOR ("()", CALL_EXPR, "cl", OVL_OP_FLAG_NONE) + +/* Operators needed for mangling. */ +DEF_SIMPLE_OPERATOR (NULL, CAST_EXPR, "cv", OVL_OP_FLAG_NONE) +DEF_SIMPLE_OPERATOR (NULL, DYNAMIC_CAST_EXPR, "dc", OVL_OP_FLAG_NONE) +DEF_SIMPLE_OPERATOR (NULL, REINTERPRET_CAST_EXPR, "rc", OVL_OP_FLAG_NONE) +DEF_SIMPLE_OPERATOR (NULL, CONST_CAST_EXPR, "cc", OVL_OP_FLAG_NONE) +DEF_SIMPLE_OPERATOR (NULL, STATIC_CAST_EXPR, "sc", OVL_OP_FLAG_NONE) +DEF_SIMPLE_OPERATOR (NULL, SCOPE_REF, "sr", OVL_OP_FLAG_NONE) +DEF_SIMPLE_OPERATOR (NULL, EXPR_PACK_EXPANSION, "sp", OVL_OP_FLAG_NONE) +DEF_SIMPLE_OPERATOR (NULL, UNARY_LEFT_FOLD_EXPR, "fl", OVL_OP_FLAG_NONE) +DEF_SIMPLE_OPERATOR (NULL, UNARY_RIGHT_FOLD_EXPR, "fr", OVL_OP_FLAG_NONE) +DEF_SIMPLE_OPERATOR (NULL, BINARY_LEFT_FOLD_EXPR, "fL", OVL_OP_FLAG_NONE) +DEF_SIMPLE_OPERATOR (NULL, BINARY_RIGHT_FOLD_EXPR, "fR", OVL_OP_FLAG_NONE) /* Assignment operators. */ DEF_ASSN_OPERATOR ("=", NOP_EXPR, "aS", OVL_OP_FLAG_BINARY) @@ -149,15 +157,3 @@ DEF_ASSN_OPERATOR ("^=", BIT_XOR_EXPR, " DEF_ASSN_OPERATOR ("<<=", LSHIFT_EXPR, "lS", OVL_OP_FLAG_BINARY) DEF_ASSN_OPERATOR (">>=", RSHIFT_EXPR, "rS", OVL_OP_FLAG_BINARY) -/* Ternary operators. */ -DEF_SIMPLE_OPERATOR ("?:", COND_EXPR, "qu", OVL_OP_FLAG_NONE) - -/* Miscellaneous. */ -DEF_SIMPLE_OPERATOR ("()", CALL_EXPR, "cl", OVL_OP_FLAG_NONE) - -/* Variadic templates extension. */ -DEF_SIMPLE_OPERATOR ("...", EXPR_PACK_EXPANSION, "sp", OVL_OP_FLAG_UNARY) -DEF_SIMPLE_OPERATOR ("... +", UNARY_LEFT_FOLD_EXPR, "fl", OVL_OP_FLAG_BINARY) -DEF_SIMPLE_OPERATOR ("+ ...", UNARY_RIGHT_FOLD_EXPR, "fr", OVL_OP_FLAG_BINARY) -DEF_SIMPLE_OPERATOR ("+ ... +", BINARY_LEFT_FOLD_EXPR, "fL", OVL_OP_FLAG_NONE) -DEF_SIMPLE_OPERATOR ("+ ... +", BINARY_RIGHT_FOLD_EXPR, "fR", OVL_OP_FLAG_NONE)