public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* C PATCH to remove unused block of code
@ 2017-08-17 10:49 Marek Polacek
  2017-08-17 14:19 ` Joseph Myers
  0 siblings, 1 reply; 3+ messages in thread
From: Marek Polacek @ 2017-08-17 10:49 UTC (permalink / raw)
  To: GCC Patches, Joseph Myers

I've been itching to remove this code for some time now.  The comment suggests
that the code is actually unused, so I replaced the body of that "else if" with
gcc_unreachable (); and ran regtest/bootstrap and nothing broke, so I propose
to do away with it.

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

2017-08-17  Marek Polacek  <polacek@redhat.com>

	* c-parser.c (c_parser_postfix_expression): Remove unused code.

diff --git gcc/c/c-parser.c gcc/c/c-parser.c
index 1402ba67204..8511a8b4fe7 100644
--- gcc/c/c-parser.c
+++ gcc/c/c-parser.c
@@ -7943,28 +7943,6 @@ c_parser_postfix_expression (c_parser *parser)
 	  set_c_expr_source_range (&expr, loc, close_loc);
 	  mark_exp_read (expr.value);
 	}
-      else if (c_token_starts_typename (c_parser_peek_2nd_token (parser)))
-	{
-	  /* A compound literal.  ??? Can we actually get here rather
-	     than going directly to
-	     c_parser_postfix_expression_after_paren_type from
-	     elsewhere?  */
-	  location_t loc;
-	  struct c_type_name *type_name;
-	  c_parser_consume_token (parser);
-	  loc = c_parser_peek_token (parser)->location;
-	  type_name = c_parser_type_name (parser);
-	  c_parser_skip_until_found (parser, CPP_CLOSE_PAREN,
-				     "expected %<)%>");
-	  if (type_name == NULL)
-	    {
-	      expr.set_error ();
-	    }
-	  else
-	    expr = c_parser_postfix_expression_after_paren_type (parser,
-								 type_name,
-								 loc);
-	}
       else
 	{
 	  /* A parenthesized expression.  */

	Marek

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: C PATCH to remove unused block of code
  2017-08-17 10:49 C PATCH to remove unused block of code Marek Polacek
@ 2017-08-17 14:19 ` Joseph Myers
  2017-08-18 13:43   ` Marek Polacek
  0 siblings, 1 reply; 3+ messages in thread
From: Joseph Myers @ 2017-08-17 14:19 UTC (permalink / raw)
  To: Marek Polacek; +Cc: GCC Patches

On Thu, 17 Aug 2017, Marek Polacek wrote:

> I've been itching to remove this code for some time now.  The comment suggests
> that the code is actually unused, so I replaced the body of that "else if" with
> gcc_unreachable (); and ran regtest/bootstrap and nothing broke, so I propose
> to do away with it.
> 
> Bootstrapped/regtested on x86_64-linux, ok for trunk?

OK, with an appropriate change to the comment above the 
c_parser_postfix_expression function to say that compound literals are not 
handled here and callers have to call 
c_parser_postfix_expression_after_paren_type on encountering them.  (I've 
reviewed all paths to c_parser_postfix_expression in the current parser 
and don't think any of them can send compound literals to it, because 
either they are parsing a specific more restricted syntax incompatible 
with compond literals (OMP cases), are parsing an expression that might be 
a cast expression so need to parse the (type) first to distinguish, or are 
parsing a context such as sizeof where a parenthesized type name is 
allowed as well as a postfix expression and again need to parse the (type) 
first to distinguish.)

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: C PATCH to remove unused block of code
  2017-08-17 14:19 ` Joseph Myers
@ 2017-08-18 13:43   ` Marek Polacek
  0 siblings, 0 replies; 3+ messages in thread
From: Marek Polacek @ 2017-08-18 13:43 UTC (permalink / raw)
  To: Joseph Myers; +Cc: GCC Patches

On Thu, Aug 17, 2017 at 02:17:31PM +0000, Joseph Myers wrote:
> On Thu, 17 Aug 2017, Marek Polacek wrote:
> 
> > I've been itching to remove this code for some time now.  The comment suggests
> > that the code is actually unused, so I replaced the body of that "else if" with
> > gcc_unreachable (); and ran regtest/bootstrap and nothing broke, so I propose
> > to do away with it.
> > 
> > Bootstrapped/regtested on x86_64-linux, ok for trunk?
> 
> OK, with an appropriate change to the comment above the 
> c_parser_postfix_expression function to say that compound literals are not 
> handled here and callers have to call 
> c_parser_postfix_expression_after_paren_type on encountering them.  (I've 
> reviewed all paths to c_parser_postfix_expression in the current parser 
> and don't think any of them can send compound literals to it, because 
> either they are parsing a specific more restricted syntax incompatible 
> with compond literals (OMP cases), are parsing an expression that might be 
> a cast expression so need to parse the (type) first to distinguish, or are 
> parsing a context such as sizeof where a parenthesized type name is 
> allowed as well as a postfix expression and again need to parse the (type) 
> first to distinguish.)

Thanks for verifying.  Here's what I'm going to install:

2017-08-18  Marek Polacek  <polacek@redhat.com>

	* c-parser.c (c_parser_postfix_expression): Remove unused code.  Update
	commentary.

diff --git gcc/c/c-parser.c gcc/c/c-parser.c
index 1402ba67204..5c965d4420d 100644
--- gcc/c/c-parser.c
+++ gcc/c/c-parser.c
@@ -7752,7 +7752,8 @@ c_parser_generic_selection (c_parser *parser)
 }
 
 /* Parse a postfix expression (C90 6.3.1-6.3.2, C99 6.5.1-6.5.2,
-   C11 6.5.1-6.5.2).
+   C11 6.5.1-6.5.2).  Compound literals aren't handled here; callers have to
+   call c_parser_postfix_expression_after_paren_type on encountering them.
 
    postfix-expression:
      primary-expression
@@ -7792,7 +7793,7 @@ c_parser_generic_selection (c_parser *parser)
      __builtin_types_compatible_p ( type-name , type-name )
      __builtin_complex ( assignment-expression , assignment-expression )
      __builtin_shuffle ( assignment-expression , assignment-expression )
-     __builtin_shuffle ( assignment-expression , 
+     __builtin_shuffle ( assignment-expression ,
 			 assignment-expression ,
 			 assignment-expression, )
 
@@ -7943,28 +7944,6 @@ c_parser_postfix_expression (c_parser *parser)
 	  set_c_expr_source_range (&expr, loc, close_loc);
 	  mark_exp_read (expr.value);
 	}
-      else if (c_token_starts_typename (c_parser_peek_2nd_token (parser)))
-	{
-	  /* A compound literal.  ??? Can we actually get here rather
-	     than going directly to
-	     c_parser_postfix_expression_after_paren_type from
-	     elsewhere?  */
-	  location_t loc;
-	  struct c_type_name *type_name;
-	  c_parser_consume_token (parser);
-	  loc = c_parser_peek_token (parser)->location;
-	  type_name = c_parser_type_name (parser);
-	  c_parser_skip_until_found (parser, CPP_CLOSE_PAREN,
-				     "expected %<)%>");
-	  if (type_name == NULL)
-	    {
-	      expr.set_error ();
-	    }
-	  else
-	    expr = c_parser_postfix_expression_after_paren_type (parser,
-								 type_name,
-								 loc);
-	}
       else
 	{
 	  /* A parenthesized expression.  */

	Marek

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-08-18 12:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-17 10:49 C PATCH to remove unused block of code Marek Polacek
2017-08-17 14:19 ` Joseph Myers
2017-08-18 13:43   ` Marek Polacek

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).