* [C++ PATCH] parser indentation cleanup
@ 2017-06-29 14:21 Nathan Sidwell
0 siblings, 0 replies; only message in thread
From: Nathan Sidwell @ 2017-06-29 14:21 UTC (permalink / raw)
To: GCC Patches
[-- Attachment #1: Type: text/plain, Size: 433 bytes --]
This is almost a reformatting diff, converting
if (cond) {
if (a) A
else B
} else C
into
if (!cond) C;
else if (a) A
else B
but it also removes an unnecessary constructor_name assignment:
if ( ... constructor_name_p (unqualified_name, class_type))
{
unqualified_name = constructor_name (class_type);
...
We've just checked it already is the constructor name.
applied to trunk.
nathan
--
Nathan Sidwell
[-- Attachment #2: parse-form.diff --]
[-- Type: text/x-patch, Size: 2630 bytes --]
2017-06-29 Nathan Sidwell <nathan@acm.org>
* parser.c (cp_parser_direct_declarator): Reorder if to avoid
indentation. Remove unnecessary assignment of constructor name.
Index: parser.c
===================================================================
--- parser.c (revision 249779)
+++ parser.c (working copy)
@@ -20106,26 +20106,8 @@ cp_parser_direct_declarator (cp_parser*
if (TREE_CODE (unqualified_name) == TYPE_DECL)
{
tree name_type = TREE_TYPE (unqualified_name);
- if (class_type && same_type_p (name_type, class_type))
- {
- if (qualifying_scope
- && CLASSTYPE_USE_TEMPLATE (name_type))
- {
- error_at (declarator_id_start_token->location,
- "invalid use of constructor as a template");
- inform (declarator_id_start_token->location,
- "use %<%T::%D%> instead of %<%T::%D%> to "
- "name the constructor in a qualified name",
- class_type,
- DECL_NAME (TYPE_TI_TEMPLATE (class_type)),
- class_type, name_type);
- declarator = cp_error_declarator;
- break;
- }
- else
- unqualified_name = constructor_name (class_type);
- }
- else
+
+ if (!class_type || !same_type_p (name_type, class_type))
{
/* We do not attempt to print the declarator
here because we do not have enough
@@ -20135,6 +20117,21 @@ cp_parser_direct_declarator (cp_parser*
declarator = cp_error_declarator;
break;
}
+ else if (qualifying_scope
+ && CLASSTYPE_USE_TEMPLATE (name_type))
+ {
+ error_at (declarator_id_start_token->location,
+ "invalid use of constructor as a template");
+ inform (declarator_id_start_token->location,
+ "use %<%T::%D%> instead of %<%T::%D%> to "
+ "name the constructor in a qualified name",
+ class_type,
+ DECL_NAME (TYPE_TI_TEMPLATE (class_type)),
+ class_type, name_type);
+ declarator = cp_error_declarator;
+ break;
+ }
+ unqualified_name = constructor_name (class_type);
}
if (class_type)
@@ -20164,14 +20161,10 @@ cp_parser_direct_declarator (cp_parser*
struct S {
friend void N::S();
}; */
- && !(friend_p
- && class_type != qualifying_scope)
+ && (!friend_p || class_type == qualifying_scope)
&& constructor_name_p (unqualified_name,
class_type))
- {
- unqualified_name = constructor_name (class_type);
- sfk = sfk_constructor;
- }
+ sfk = sfk_constructor;
else if (is_overloaded_fn (unqualified_name)
&& DECL_CONSTRUCTOR_P (get_first_fn
(unqualified_name)))
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2017-06-29 14:21 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-29 14:21 [C++ PATCH] parser indentation cleanup Nathan Sidwell
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).