public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [RFA] statement before variable declaration  in cp_parser_initializer_list.
@ 2013-01-03 12:31 Joel Brobecker
  2013-01-03 12:33 ` Richard Biener
  0 siblings, 1 reply; 8+ messages in thread
From: Joel Brobecker @ 2013-01-03 12:31 UTC (permalink / raw)
  To: gcc-patches; +Cc: Joel Brobecker

Hello,

I happened to notice a warning while compiling GCC, and it seemed
like an easy fix...

gcc/cp/ChangeLog:

        * parser.c (cp_parser_initializer_list): Move declaration
        of variable non_const to start of lexical block.

Tested against x86_64-linux, no regression.
OK to commit? (obvious?)

Thanks,
-- 
Joel

---
 gcc/cp/parser.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 3dc2ec6..61d93f8 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -17932,9 +17932,10 @@ cp_parser_initializer_list (cp_parser* parser, bool* non_constant_p)
 	       && cp_lexer_next_token_is (parser->lexer, CPP_OPEN_SQUARE))
 	{
 	  /* In C++11, [ could start a lambda-introducer.  */
+	  bool non_const = false;
+
 	  cp_parser_parse_tentatively (parser);
 	  cp_lexer_consume_token (parser->lexer);
-	  bool non_const = false;
 	  designator = cp_parser_constant_expression (parser, true, &non_const);
 	  cp_parser_require (parser, CPP_CLOSE_SQUARE, RT_CLOSE_SQUARE);
 	  cp_parser_require (parser, CPP_EQ, RT_EQ);
-- 
1.7.0.4

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

* Re: [RFA] statement before variable declaration in cp_parser_initializer_list.
  2013-01-03 12:31 [RFA] statement before variable declaration in cp_parser_initializer_list Joel Brobecker
@ 2013-01-03 12:33 ` Richard Biener
  2013-01-03 12:37   ` Joel Brobecker
  2013-01-03 12:55   ` Eric Botcazou
  0 siblings, 2 replies; 8+ messages in thread
From: Richard Biener @ 2013-01-03 12:33 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gcc-patches

On Thu, Jan 3, 2013 at 1:30 PM, Joel Brobecker <brobecker@adacore.com> wrote:
> Hello,
>
> I happened to notice a warning while compiling GCC, and it seemed
> like an easy fix...
>
> gcc/cp/ChangeLog:
>
>         * parser.c (cp_parser_initializer_list): Move declaration
>         of variable non_const to start of lexical block.
>
> Tested against x86_64-linux, no regression.
> OK to commit? (obvious?)

Hmm?  We compile with a C++ compiler where this is perfectly valid ...

Richard.

> Thanks,
> --
> Joel
>
> ---
>  gcc/cp/parser.c |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
> index 3dc2ec6..61d93f8 100644
> --- a/gcc/cp/parser.c
> +++ b/gcc/cp/parser.c
> @@ -17932,9 +17932,10 @@ cp_parser_initializer_list (cp_parser* parser, bool* non_constant_p)
>                && cp_lexer_next_token_is (parser->lexer, CPP_OPEN_SQUARE))
>         {
>           /* In C++11, [ could start a lambda-introducer.  */
> +         bool non_const = false;
> +
>           cp_parser_parse_tentatively (parser);
>           cp_lexer_consume_token (parser->lexer);
> -         bool non_const = false;
>           designator = cp_parser_constant_expression (parser, true, &non_const);
>           cp_parser_require (parser, CPP_CLOSE_SQUARE, RT_CLOSE_SQUARE);
>           cp_parser_require (parser, CPP_EQ, RT_EQ);
> --
> 1.7.0.4
>

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

* Re: [RFA] statement before variable declaration in cp_parser_initializer_list.
  2013-01-03 12:33 ` Richard Biener
@ 2013-01-03 12:37   ` Joel Brobecker
  2013-01-03 12:57     ` Richard Biener
  2013-01-03 12:55   ` Eric Botcazou
  1 sibling, 1 reply; 8+ messages in thread
From: Joel Brobecker @ 2013-01-03 12:37 UTC (permalink / raw)
  To: Richard Biener; +Cc: gcc-patches

> > Tested against x86_64-linux, no regression.
> > OK to commit? (obvious?)
> 
> Hmm?  We compile with a C++ compiler where this is perfectly valid ...

I was compiling with GCC 4.7 where it gave me a warning... I don't know
much about C++ anymore, so I didn't know. Oh well!

-- 
Joel

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

* Re: [RFA] statement before variable declaration in cp_parser_initializer_list.
  2013-01-03 12:33 ` Richard Biener
  2013-01-03 12:37   ` Joel Brobecker
@ 2013-01-03 12:55   ` Eric Botcazou
  1 sibling, 0 replies; 8+ messages in thread
From: Eric Botcazou @ 2013-01-03 12:55 UTC (permalink / raw)
  To: Richard Biener; +Cc: gcc-patches, Joel Brobecker

> Hmm?  We compile with a C++ compiler where this is perfectly valid ...

Not on earlier branches though, e.g. the 4.7 branch.  So I would install it 
everywhere to avoid gratuitous differences.

-- 
Eric Botcazou

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

* Re: [RFA] statement before variable declaration in cp_parser_initializer_list.
  2013-01-03 12:37   ` Joel Brobecker
@ 2013-01-03 12:57     ` Richard Biener
  2013-01-08 11:37       ` Joel Brobecker
  0 siblings, 1 reply; 8+ messages in thread
From: Richard Biener @ 2013-01-03 12:57 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gcc-patches

On Thu, Jan 3, 2013 at 1:37 PM, Joel Brobecker <brobecker@adacore.com> wrote:
>> > Tested against x86_64-linux, no regression.
>> > OK to commit? (obvious?)
>>
>> Hmm?  We compile with a C++ compiler where this is perfectly valid ...
>
> I was compiling with GCC 4.7 where it gave me a warning... I don't know
> much about C++ anymore, so I didn't know. Oh well!

Ah, for the 4.7 branch yes.

Thanks,
Richard.

> --
> Joel

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

* Re: [RFA] statement before variable declaration in cp_parser_initializer_list.
  2013-01-03 12:57     ` Richard Biener
@ 2013-01-08 11:37       ` Joel Brobecker
  2013-01-08 11:51         ` Richard Biener
  0 siblings, 1 reply; 8+ messages in thread
From: Joel Brobecker @ 2013-01-08 11:37 UTC (permalink / raw)
  To: Richard Biener; +Cc: gcc-patches

Hi Richard,

> >> Hmm?  We compile with a C++ compiler where this is perfectly valid ...
> >
> > I was compiling with GCC 4.7 where it gave me a warning... I don't know
> > much about C++ anymore, so I didn't know. Oh well!
> 
> Ah, for the 4.7 branch yes.

Eric Botcazou asked that we have the same code for both 4.7 and HEAD.
Would it be OK to apply it to both? It's not really strictly
necessary for the HEAD, but I don't see it as being harmful either.

Thank you!
-- 
Joel

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

* Re: [RFA] statement before variable declaration in cp_parser_initializer_list.
  2013-01-08 11:37       ` Joel Brobecker
@ 2013-01-08 11:51         ` Richard Biener
  2013-01-08 12:36           ` Joel Brobecker
  0 siblings, 1 reply; 8+ messages in thread
From: Richard Biener @ 2013-01-08 11:51 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gcc-patches

On Tue, Jan 8, 2013 at 12:37 PM, Joel Brobecker <brobecker@adacore.com> wrote:
> Hi Richard,
>
>> >> Hmm?  We compile with a C++ compiler where this is perfectly valid ...
>> >
>> > I was compiling with GCC 4.7 where it gave me a warning... I don't know
>> > much about C++ anymore, so I didn't know. Oh well!
>>
>> Ah, for the 4.7 branch yes.
>
> Eric Botcazou asked that we have the same code for both 4.7 and HEAD.
> Would it be OK to apply it to both? It's not really strictly
> necessary for the HEAD, but I don't see it as being harmful either.

Sure.

Richard.

> Thank you!
> --
> Joel

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

* Re: [RFA] statement before variable declaration in cp_parser_initializer_list.
  2013-01-08 11:51         ` Richard Biener
@ 2013-01-08 12:36           ` Joel Brobecker
  0 siblings, 0 replies; 8+ messages in thread
From: Joel Brobecker @ 2013-01-08 12:36 UTC (permalink / raw)
  To: Richard Biener; +Cc: gcc-patches

> > Eric Botcazou asked that we have the same code for both 4.7 and HEAD.
> > Would it be OK to apply it to both? It's not really strictly
> > necessary for the HEAD, but I don't see it as being harmful either.
> 
> Sure.

Thank you! Now checked in.

-- 
Joel

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

end of thread, other threads:[~2013-01-08 12:36 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-03 12:31 [RFA] statement before variable declaration in cp_parser_initializer_list Joel Brobecker
2013-01-03 12:33 ` Richard Biener
2013-01-03 12:37   ` Joel Brobecker
2013-01-03 12:57     ` Richard Biener
2013-01-08 11:37       ` Joel Brobecker
2013-01-08 11:51         ` Richard Biener
2013-01-08 12:36           ` Joel Brobecker
2013-01-03 12:55   ` Eric Botcazou

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