From: Nathan Sidwell <nathan@acm.org>
To: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: [C++ PATCH] overloaded operator fns [4/N]
Date: Tue, 31 Oct 2017 18:45:00 -0000 [thread overview]
Message-ID: <006c8467-dde6-1605-243c-f8d033ab4e49@acm.org> (raw)
In-Reply-To: <c46a6883-2675-2457-7bef-7e8a2a19cbb5@acm.org>
[-- Attachment #1: Type: text/plain, Size: 440 bytes --]
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
--
Nathan Sidwell
[-- Attachment #2: op-ident-4.diff --]
[-- Type: text/x-patch, Size: 6111 bytes --]
2017-10-31 Nathan Sidwell <nathan@acm.org>
* 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 ("<invalid operator>");
-
- /* 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)
next prev parent reply other threads:[~2017-10-31 18:28 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-31 13:12 [C++ PATCH] overloaded operator fns [1/N] Nathan Sidwell
2017-10-31 14:45 ` [C++ PATCH] overloaded operator fns [2/N] Nathan Sidwell
2017-10-31 16:30 ` [C++ PATCH] overloaded operator fns [3/N] Nathan Sidwell
2017-10-31 18:45 ` Nathan Sidwell [this message]
2017-10-31 20:20 ` [C++ PATCH] overloaded operator fns [5/N] Nathan Sidwell
2017-11-01 14:02 ` [C++ PATCH] overloaded operator fns [6/N] Nathan Sidwell
2017-11-01 15:45 ` Nathan Sidwell
2017-11-01 18:29 ` [C++ PATCH] overloaded operator fns [8/N] Nathan Sidwell
2017-11-01 20:09 ` Jason Merrill
2017-11-02 14:15 ` Nathan Sidwell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=006c8467-dde6-1605-243c-f8d033ab4e49@acm.org \
--to=nathan@acm.org \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).