This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: RFC: Wextra digest (fixing PR7651)


"Manuel LÃpez-IbÃÃez" <lopezibanez@gmail.com> writes:

> The goal is to fix PR7651 and convert Wextra into a super-option, that
> is an -W* option that just enables other options but it doesn't emit
> warnings by itself (other super-options are Wall and Wunused).

Thanks again for tackling this.

These issues are tricky because on the one hand we don't want too many
different options, and on the other hand we want to give people the
control they are asking for with regard to turning off warnings.


> * Subscripting an array which has been declared register.
> 
> * Taking the address of a variable which has been declared register.

Hmmm.  In the C frontend these are pedwarns.  But the C++ frontend
doesn't have pedwarns.  And maybe C++ doesn't require these warnings
anyhow, I don't know.  -Winvalid-register anyone?

> * A base class is not initialized in a derived class' copy constructor.

I think -Wuninitialized.

> * A non-static reference or non-static const member appears in a class
> without constructors.

-Wbad-code.  Or, I dunno, how about -Wmissing-field-initializers?

> * Ambiguous virtual bases (virtual base inaccessible due to
> ambiguity). (There is also an unconditional warning for direct base
> inaccessible due to ambiguity)

What do you think of -Woverloaded-virtual?

> * An enumerator and a non-enumerator both appear in a conditional
> expression. (There is also an unconditional warning for two different
> enumeral types used in a conditional expression).

Maybe we should rename -Wswitch-enum to -Wenum and wrap these warnings
under there as well.

> * A function can return either with or without a value.

I give up.

> * An expression-statement or the left-hand side of a comma expression
> contains no side effects. For example, an expression such as x[i,j].
> This is also warned by Wunused-value. In addition, Wextra enables
> Wunused-value but this is not documented (and -Wunused-value is
> already enabled by -Wall).

I think this should just be -WUnused-value.

> * A pointer is compared against integer zero with <, <=, >, or >=.
> This is a pedwarn and it can also be enabled by using -pedantic. If
> the pointer is the rightmost operator, there is no warning for Wextra
> (surely a bug).

-Wpointer-arith, maybe.

> * An unsigned value is compared against zero with < or >=.
> Walways-true claims to warn for this but it doesn't. There is also an
> unconditional warning for expressions that are always true or false
> due to the range of types.

-Walways-true should warn for this.

> In ./gcc/config/sh/symbian.c:158 there is a warning enabled by Wextra
> with the following code (notice the OPT_Wattributes) :
> 
>   /* We ignore the dllimport attribute for inline member functions.
>      This differs from MSVC behavior which treats it like GNUC
>      'extern inline' extension.   */
>   else if (TREE_CODE (decl) == FUNCTION_DECL && DECL_INLINE (decl))
>     {
>       if (extra_warnings)
> 	warning (OPT_Wattributes, "inline function %q+D is declared as "
> 		 "dllimport: attribute ignored",
> 		 decl);
>       return false;
>     }

Just drop the test of extra_warnings, I think.

> Finally, the manual page claims that Wextra warns for any of several
> floating-point events that often indicate errors, such as overflow,
> underflow, loss of precision, etc. I wasn't able to find any instance
> of this. I am fairly sure that Wextra doesn't do such thing.

I have no idea what that refers to.

Thanks again.  Hope this helps.  No doubt others will disagree with
some of my comments.

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]