* [C++ Patch] Fix cp_parser_unqualified_id typo
@ 2019-05-31 9:26 Paolo Carlini
2019-06-03 17:34 ` Jason Merrill
0 siblings, 1 reply; 2+ messages in thread
From: Paolo Carlini @ 2019-05-31 9:26 UTC (permalink / raw)
To: gcc-patches; +Cc: Jason Merrill
[-- Attachment #1: Type: text/plain, Size: 527 bytes --]
Hi,
noticed this typo: we are passing the location to build_nt as third
argument instead of passing it to cp_expr as second argument. Tested
x86_64-linux.
By the way, we have the option of using build_min_nt_loc instead of
build_nt in all these places for BIT_NOT_EXPR in
cp_parser_unqualified_id, Certainly it has the advantage that the
location information survives in the tree node when cp_expr is
eventually converted to a plain tree... (below tests fine) What do you
think?
Thanks, Paolo.
////////////////////
[-- Attachment #2: CL --]
[-- Type: text/plain, Size: 140 bytes --]
2019-05-31 Paolo Carlini <paolo.carlini@oracle.com>
* parser.c (cp_parser_unqualified_id): Fix typo, properly call
build_nt.
[-- Attachment #3: patchlet --]
[-- Type: text/plain, Size: 554 bytes --]
Index: parser.c
===================================================================
--- parser.c (revision 271785)
+++ parser.c (working copy)
@@ -6063,7 +6063,7 @@ cp_parser_unqualified_id (cp_parser* parser,
"%<~auto%> only available with "
"%<-std=c++14%> or %<-std=gnu++14%>");
cp_lexer_consume_token (parser->lexer);
- return cp_expr (build_nt (BIT_NOT_EXPR, make_auto (), loc));
+ return cp_expr (build_nt (BIT_NOT_EXPR, make_auto ()), loc);
}
/* If there was an explicit qualification (S::~T), first look
[-- Attachment #4: p4 --]
[-- Type: text/plain, Size: 2033 bytes --]
Index: parser.c
===================================================================
--- parser.c (revision 271761)
+++ parser.c (working copy)
@@ -6052,7 +6052,7 @@ cp_parser_unqualified_id (cp_parser* parser,
&& constructor_name_p (token->u.value, scope))))
{
cp_lexer_consume_token (parser->lexer);
- return cp_expr (build_nt (BIT_NOT_EXPR, scope), loc);
+ return build_min_nt_loc (loc, BIT_NOT_EXPR, scope);
}
/* ~auto means the destructor of whatever the object is. */
@@ -6063,7 +6063,7 @@ cp_parser_unqualified_id (cp_parser* parser,
"%<~auto%> only available with "
"%<-std=c++14%> or %<-std=gnu++14%>");
cp_lexer_consume_token (parser->lexer);
- return cp_expr (build_nt (BIT_NOT_EXPR, make_auto (), loc));
+ return build_min_nt_loc (loc, BIT_NOT_EXPR, make_auto ());
}
/* If there was an explicit qualification (S::~T), first look
@@ -6153,8 +6153,8 @@ cp_parser_unqualified_id (cp_parser* parser,
time. */
type_decl = cp_parser_identifier (parser);
if (type_decl != error_mark_node)
- type_decl = build_nt (BIT_NOT_EXPR, type_decl);
- return cp_expr (type_decl, loc);
+ type_decl = build_min_nt_loc (loc, BIT_NOT_EXPR, type_decl);
+ return type_decl;
}
}
/* If an error occurred, assume that the name of the
@@ -6162,7 +6162,7 @@ cp_parser_unqualified_id (cp_parser* parser,
class. That allows us to keep parsing after running
into ill-formed destructor names. */
if (type_decl == error_mark_node && scope)
- return build_nt (BIT_NOT_EXPR, scope);
+ return build_min_nt_loc (loc, BIT_NOT_EXPR, scope);
else if (type_decl == error_mark_node)
return error_mark_node;
@@ -6189,7 +6189,7 @@ cp_parser_unqualified_id (cp_parser* parser,
"typedef-name %qD used as destructor declarator",
type_decl);
- return cp_expr (build_nt (BIT_NOT_EXPR, TREE_TYPE (type_decl), loc));
+ return build_min_nt_loc (loc, BIT_NOT_EXPR, TREE_TYPE (type_decl));
}
case CPP_KEYWORD:
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [C++ Patch] Fix cp_parser_unqualified_id typo
2019-05-31 9:26 [C++ Patch] Fix cp_parser_unqualified_id typo Paolo Carlini
@ 2019-06-03 17:34 ` Jason Merrill
0 siblings, 0 replies; 2+ messages in thread
From: Jason Merrill @ 2019-06-03 17:34 UTC (permalink / raw)
To: Paolo Carlini, gcc-patches
On 5/31/19 5:05 AM, Paolo Carlini wrote:
>
> By the way, we have the option of using build_min_nt_loc instead of
> build_nt in all these places for BIT_NOT_EXPR in
> cp_parser_unqualified_id, Certainly it has the advantage that the
> location information survives in the tree node when cp_expr is
> eventually converted to a plain tree... (below tests fine) What do you
> think?
This patch is OK.
Jason
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-06-03 17:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-31 9:26 [C++ Patch] Fix cp_parser_unqualified_id typo Paolo Carlini
2019-06-03 17:34 ` Jason Merrill
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).