Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* Should we fix warnings from GCC 2.xx?
@ 2002-09-11 16:43 Joel Brobecker
  2002-09-12  8:53 ` Andrew Cagney
  2002-09-19  4:12 ` Eli Zaretskii
  0 siblings, 2 replies; 7+ messages in thread
From: Joel Brobecker @ 2002-09-11 16:43 UTC (permalink / raw)
  To: gdb-patches

While building GDB from CVS on my Linux machines, I saw a few warnings
like this one:

> tracepoint.c: In function `trace_find_tracepoint_command':
> tracepoint.c:2077: warning: suggest explicit braces to avoid ambiguous `else'

This warning appears with a GCC 2.8.1-based compiler, but does not
with GCC 3.0.4. Hence my question, do we want to fix these warnings
anyway?

I guess for a lot of warnings, the fix are quite straghtforward, like
this:
<<
Index: tracepoint.c
===================================================================
RCS file: /cvs/src/src/gdb/tracepoint.c,v
retrieving revision 1.40
diff -c -3 -p -r1.40 tracepoint.c
*** tracepoint.c	24 Jul 2002 17:58:46 -0000	1.40
--- tracepoint.c	11 Sep 2002 23:33:52 -0000
*************** trace_find_tracepoint_command (char *arg
*** 2071,2080 ****
    if (target_is_remote ())
      {
        if (args == 0 || *args == 0)
! 	if (tracepoint_number == -1)
! 	  error ("No current tracepoint -- please supply an argument.");
! 	else
! 	  tdp = tracepoint_number;	/* default is current TDP */
        else
  	tdp = parse_and_eval_long (args);
  
--- 2071,2082 ----
    if (target_is_remote ())
      {
        if (args == 0 || *args == 0)
!         {
! 	    if (tracepoint_number == -1)
! 	      error ("No current tracepoint -- please supply an argument.");
! 	    else
! 	      tdp = tracepoint_number;	/* default is current TDP */
!         }
        else
  	tdp = parse_and_eval_long (args);
  
>>

-- 
Joel


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

* Re: Should we fix warnings from GCC 2.xx?
  2002-09-11 16:43 Should we fix warnings from GCC 2.xx? Joel Brobecker
@ 2002-09-12  8:53 ` Andrew Cagney
  2002-09-12 11:50   ` Joel Brobecker
  2002-09-19  4:12 ` Eli Zaretskii
  1 sibling, 1 reply; 7+ messages in thread
From: Andrew Cagney @ 2002-09-12  8:53 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches

> While building GDB from CVS on my Linux machines, I saw a few warnings
> like this one:
> 
> 
>> tracepoint.c: In function `trace_find_tracepoint_command':
>> tracepoint.c:2077: warning: suggest explicit braces to avoid ambiguous `else'
> 
> 
> This warning appears with a GCC 2.8.1-based compiler, but does not
> with GCC 3.0.4. Hence my question, do we want to fix these warnings
> anyway?

Regardless, I don't see how it can hurt.  Removes the dangling `else' 
problem.

Andrew


> I guess for a lot of warnings, the fix are quite straghtforward, like
> this:
> <<
> Index: tracepoint.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/tracepoint.c,v
> retrieving revision 1.40
> diff -c -3 -p -r1.40 tracepoint.c
> *** tracepoint.c	24 Jul 2002 17:58:46 -0000	1.40
> --- tracepoint.c	11 Sep 2002 23:33:52 -0000
> *************** trace_find_tracepoint_command (char *arg
> *** 2071,2080 ****
>     if (target_is_remote ())
>       {
>         if (args == 0 || *args == 0)
> ! 	if (tracepoint_number == -1)
> ! 	  error ("No current tracepoint -- please supply an argument.");
> ! 	else
> ! 	  tdp = tracepoint_number;	/* default is current TDP */
>         else
>   	tdp = parse_and_eval_long (args);
>   
> --- 2071,2082 ----
>     if (target_is_remote ())
>       {
>         if (args == 0 || *args == 0)
> !         {
> ! 	    if (tracepoint_number == -1)
> ! 	      error ("No current tracepoint -- please supply an argument.");
> ! 	    else
> ! 	      tdp = tracepoint_number;	/* default is current TDP */
> !         }
>         else
>   	tdp = parse_and_eval_long (args);
>   
> 
>>>
> 
> 
> -- Joel 



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

* Re: Should we fix warnings from GCC 2.xx?
  2002-09-12  8:53 ` Andrew Cagney
@ 2002-09-12 11:50   ` Joel Brobecker
  0 siblings, 0 replies; 7+ messages in thread
From: Joel Brobecker @ 2002-09-12 11:50 UTC (permalink / raw)
  To: Andrew Cagney; +Cc: gdb-patches

> Regardless, I don't see how it can hurt.  Removes the dangling `else' 
> problem.

Ok, thanks for the clarification. I will check-in this patch shortly
and send the associated [PATCH] email as a confirmation. There is also
the exact same error in exec.c that I will fix.

-- 
Joel


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

* Re: Should we fix warnings from GCC 2.xx?
  2002-09-11 16:43 Should we fix warnings from GCC 2.xx? Joel Brobecker
  2002-09-12  8:53 ` Andrew Cagney
@ 2002-09-19  4:12 ` Eli Zaretskii
  2002-09-19  4:31   ` Andreas Schwab
  1 sibling, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2002-09-19  4:12 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches


On Wed, 11 Sep 2002, Joel Brobecker wrote:

> > tracepoint.c: In function `trace_find_tracepoint_command':
> > tracepoint.c:2077: warning: suggest explicit braces to avoid ambiguous `else'
> 
> This warning appears with a GCC 2.8.1-based compiler, but does not
> with GCC 3.0.4. Hence my question, do we want to fix these warnings
> anyway?

FWIW, I'm still using GCC 2.7.2.1 on one of my machines.


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

* Re: Should we fix warnings from GCC 2.xx?
  2002-09-19  4:12 ` Eli Zaretskii
@ 2002-09-19  4:31   ` Andreas Schwab
  2002-09-19  4:49     ` Eli Zaretskii
  0 siblings, 1 reply; 7+ messages in thread
From: Andreas Schwab @ 2002-09-19  4:31 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Joel Brobecker, gdb-patches

Eli Zaretskii <eliz@is.elta.co.il> writes:

|> On Wed, 11 Sep 2002, Joel Brobecker wrote:
|> 
|> > > tracepoint.c: In function `trace_find_tracepoint_command':
|> > > tracepoint.c:2077: warning: suggest explicit braces to avoid ambiguous `else'
|> > 
|> > This warning appears with a GCC 2.8.1-based compiler, but does not
|> > with GCC 3.0.4. Hence my question, do we want to fix these warnings
|> > anyway?

GCC 2.8 warns in one case where GCC 2.95+ does not:

    if (foo)
      if (bar)
        ;
      else
        ;
    else
      ;

|> FWIW, I'm still using GCC 2.7.2.1 on one of my machines.

GCC 2.7 does not have this warning in the first place.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, Deutschherrnstr. 15-19, D-90429 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."


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

* Re: Should we fix warnings from GCC 2.xx?
  2002-09-19  4:31   ` Andreas Schwab
@ 2002-09-19  4:49     ` Eli Zaretskii
  2002-09-19  5:03       ` Andreas Schwab
  0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2002-09-19  4:49 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: Joel Brobecker, gdb-patches


On Thu, 19 Sep 2002, Andreas Schwab wrote:

> |> FWIW, I'm still using GCC 2.7.2.1 on one of my machines.
> 
> GCC 2.7 does not have this warning in the first place.

IIRC, it does.


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

* Re: Should we fix warnings from GCC 2.xx?
  2002-09-19  4:49     ` Eli Zaretskii
@ 2002-09-19  5:03       ` Andreas Schwab
  0 siblings, 0 replies; 7+ messages in thread
From: Andreas Schwab @ 2002-09-19  5:03 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Joel Brobecker, gdb-patches

Eli Zaretskii <eliz@is.elta.co.il> writes:

|> On Thu, 19 Sep 2002, Andreas Schwab wrote:
|> 
|> > |> FWIW, I'm still using GCC 2.7.2.1 on one of my machines.
|> > 
|> > GCC 2.7 does not have this warning in the first place.
|> 
|> IIRC, it does.

It does have -Wparentheses, but it doesn't warn about braces.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, Deutschherrnstr. 15-19, D-90429 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."


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

end of thread, other threads:[~2002-09-19 12:03 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-11 16:43 Should we fix warnings from GCC 2.xx? Joel Brobecker
2002-09-12  8:53 ` Andrew Cagney
2002-09-12 11:50   ` Joel Brobecker
2002-09-19  4:12 ` Eli Zaretskii
2002-09-19  4:31   ` Andreas Schwab
2002-09-19  4:49     ` Eli Zaretskii
2002-09-19  5:03       ` Andreas Schwab

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox