diff mbox series

[C++] P0962 change cleanup (PR c++/85312)

Message ID 20180410141005.GJ8577@tucnak
State New
Headers show
Series [C++] P0962 change cleanup (PR c++/85312) | expand

Commit Message

Jakub Jelinek April 10, 2018, 2:10 p.m. UTC
Hi!

The "Implement P0962" change changed the
if (member_begin != NULL_TREE || member_end != NULL_TREE)
condition to
if (member_begin != NULL_TREE && member_end != NULL_TREE)
but that created a lot of dead-code, because now the diagnostics in that
if is unreachable, we are always guaranteed both member_begin and member_end
are non-NULL in that block.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2018-04-10  Jakub Jelinek  <jakub@redhat.com>

	PR c++/85312 - P0962 cleanup
	* parser.c (cp_parser_perform_range_for_lookup): Remove unreachable
	diagnostics.


	Jakub

Comments

Ville Voutilainen April 10, 2018, 2:18 p.m. UTC | #1
On 10 April 2018 at 17:10, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> The "Implement P0962" change changed the
> if (member_begin != NULL_TREE || member_end != NULL_TREE)
> condition to
> if (member_begin != NULL_TREE && member_end != NULL_TREE)
> but that created a lot of dead-code, because now the diagnostics in that
> if is unreachable, we are always guaranteed both member_begin and member_end
> are non-NULL in that block.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?


Oops; looks good to me.
Jason Merrill April 10, 2018, 2:22 p.m. UTC | #2
OK.

On Tue, Apr 10, 2018 at 10:10 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> The "Implement P0962" change changed the
> if (member_begin != NULL_TREE || member_end != NULL_TREE)
> condition to
> if (member_begin != NULL_TREE && member_end != NULL_TREE)
> but that created a lot of dead-code, because now the diagnostics in that
> if is unreachable, we are always guaranteed both member_begin and member_end
> are non-NULL in that block.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
>
> 2018-04-10  Jakub Jelinek  <jakub@redhat.com>
>
>         PR c++/85312 - P0962 cleanup
>         * parser.c (cp_parser_perform_range_for_lookup): Remove unreachable
>         diagnostics.
>
> --- gcc/cp/parser.c.jj  2018-04-10 08:52:24.697790705 +0200
> +++ gcc/cp/parser.c     2018-04-10 12:40:11.359290679 +0200
> @@ -12041,17 +12041,8 @@ cp_parser_perform_range_for_lookup (tree
>        if (member_begin != NULL_TREE && member_end != NULL_TREE)
>         {
>           /* Use the member functions.  */
> -         if (member_begin != NULL_TREE)
> -           *begin = cp_parser_range_for_member_function (range, id_begin);
> -         else
> -           error ("range-based %<for%> expression of type %qT has an "
> -                  "%<end%> member but not a %<begin%>", TREE_TYPE (range));
> -
> -         if (member_end != NULL_TREE)
> -           *end = cp_parser_range_for_member_function (range, id_end);
> -         else
> -           error ("range-based %<for%> expression of type %qT has a "
> -                  "%<begin%> member but not an %<end%>", TREE_TYPE (range));
> +         *begin = cp_parser_range_for_member_function (range, id_begin);
> +         *end = cp_parser_range_for_member_function (range, id_end);
>         }
>        else
>         {
>
>         Jakub
diff mbox series

Patch

--- gcc/cp/parser.c.jj	2018-04-10 08:52:24.697790705 +0200
+++ gcc/cp/parser.c	2018-04-10 12:40:11.359290679 +0200
@@ -12041,17 +12041,8 @@  cp_parser_perform_range_for_lookup (tree
       if (member_begin != NULL_TREE && member_end != NULL_TREE)
 	{
 	  /* Use the member functions.  */
-	  if (member_begin != NULL_TREE)
-	    *begin = cp_parser_range_for_member_function (range, id_begin);
-	  else
-	    error ("range-based %<for%> expression of type %qT has an "
-		   "%<end%> member but not a %<begin%>", TREE_TYPE (range));
-
-	  if (member_end != NULL_TREE)
-	    *end = cp_parser_range_for_member_function (range, id_end);
-	  else
-	    error ("range-based %<for%> expression of type %qT has a "
-		   "%<begin%> member but not an %<end%>", TREE_TYPE (range));
+	  *begin = cp_parser_range_for_member_function (range, id_begin);
+	  *end = cp_parser_range_for_member_function (range, id_end);
 	}
       else
 	{