This is the mail archive of the gcc-patches@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: -Wmissing-pure/-Wmissing-const/-Wmissing-nothrow


2009/7/3 Jan Hubicka <hubicka@ucw.cz>:
>> 2009/7/2 Jan Hubicka <hubicka@ucw.cz>:
>> >> 2009/7/2 Jan Hubicka <hubicka@ucw.cz>:
>> >
>> > Well, I added it there just because other warnings was there. ?I can put
>> > it to tree.h, but tree.h looks bit too generic...
>>
>> warn_deprecated_use is defined in toplev.c, so at least it makes sense
>> it is declared in toplevel.h. But it is only used by the C and C++
>
> I also need to include toplev.h for warning function itself.
>
> Here is updated patch. ?It adds comment about warnings being more active
> at hither optimization levels (nothrow is to limited degree done at -O0
> too, const/pure needs -O1 ATM), it also moves declaration to tree.h,
> updates the hashtable query. ?I didn't updated the -Wmidding-attribute=
> but if it seems better, I will do that as followup.
>
> Regtested x86_64-linux, I am re-bootstrapping now, OK?

Could you address my earlier comments?

We should distinguish between GCC attribute nothrow and
C++ 'throw()' specification.  The latter has viral effects on
function types.

Please, please change -Wmissing-attribute= to -Wattributable=
or something like that -- the programs are not potentially unsound without
the attributes.  Rather, as the comment suggests, they might profit
from the candidate attributes.

In fact, these diagnostics should be "note: ", not "warning: ".

>
> ? ? ? ?* doc/invoke.texi (-Wmissing-const, -Wmissing-pure, -Wmissing-nothrow):
> ? ? ? ?Document.
> ? ? ? ?* tree.h (warn_function_nothrow): Declare.
> ? ? ? ?* ipa-pure-const.c: Include toplev.h, flags.h and pointer-set.h.
> ? ? ? ?(function_always_visible_to_compiler_p, warn_function_nothrow,
> ? ? ? ?warn_function_pure, warn_function_const): New functions.
> ? ? ? ?(check_call): Improve debug info.
> ? ? ? ?(analyze_function): Do not check availability.
> ? ? ? ?(add_new_function): Check availability.
> ? ? ? ?(propagate): Output warnings.
> ? ? ? ?(skip_function_for_local_pure_const): New function.
> ? ? ? ?(local_pure_const): Use it; output warnings.
> ? ? ? ?* except.c (set_nothrow_function_flags): Output warnings.
> ? ? ? ?(common.opt): Add Wmissing-const, Wmissing-nothrow, Wmissing-pure.
>
>
> ? ? ? ?* cp/decl.c (finish_function): Call warn_function_nothrow.
>
> ? ? ? ?* g++.dg/opt/nothrow2.C: New testcase.
> ? ? ? ?* gcc.dg/pure-2.c: New testcase.
> ? ? ? ?* gcc.dg/const-1.c: New testcase.
> Index: doc/invoke.texi
> ===================================================================
> *** doc/invoke.texi ? ? (revision 149206)
> --- doc/invoke.texi ? ? (working copy)
> *************** Objective-C and Objective-C++ Dialects}.
> *** 244,252 ****
> ?-Wno-int-to-pointer-cast -Wno-invalid-offsetof @gol
> ?-Winvalid-pch -Wlarger-than=@var{len} ?-Wunsafe-loop-optimizations @gol
> ?-Wlogical-op -Wlong-long @gol
> ! -Wmain ?-Wmissing-braces ?-Wmissing-field-initializers @gol
> ?-Wmissing-format-attribute ?-Wmissing-include-dirs @gol
> ! -Wmissing-noreturn ?-Wno-mudflap @gol
> ?-Wno-multichar ?-Wnonnull ?-Wno-overflow @gol
> ?-Woverlength-strings ?-Wpacked ?-Wpacked-bitfield-compat ?-Wpadded @gol
> ?-Wparentheses ?-Wpedantic-ms-format -Wno-pedantic-ms-format @gol
> --- 244,252 ----
> ?-Wno-int-to-pointer-cast -Wno-invalid-offsetof @gol
> ?-Winvalid-pch -Wlarger-than=@var{len} ?-Wunsafe-loop-optimizations @gol
> ?-Wlogical-op -Wlong-long @gol
> ! -Wmain ?-Wmissing-braces -Wmissing-const -Wmissing-field-initializers @gol
> ?-Wmissing-format-attribute ?-Wmissing-include-dirs @gol
> ! -Wmissing-noreturn ?-Wmissing-nothrow -Wmissing-pure -Wno-mudflap @gol
> ?-Wno-multichar ?-Wnonnull ?-Wno-overflow @gol
> ?-Woverlength-strings ?-Wpacked ?-Wpacked-bitfield-compat ?-Wpadded @gol
> ?-Wparentheses ?-Wpedantic-ms-format -Wno-pedantic-ms-format @gol
> *************** adding the @code{noreturn} attribute, ot
> *** 3952,3957 ****
> --- 3952,3982 ----
> ?bugs could be introduced. ?You will not get a warning for @code{main} in
> ?hosted C environments.
>
> + @item -Wmissing-const
> + @opindex Wmissing-const
> + @opindex Wno-missing-const
> + @item -Wmissing-pure
> + @opindex Wmissing-pure
> + @opindex Wno-missing-pure
> + Warn about functions which might be candidates for attribute @code{const} and @code{pure}.
> + Warning is not output for functions where compiler can fully decide by itself, only

I suggest:

    The compiler does not display notes for functions where the
compiler can fully decide by
    itself, ...

> + for functions visible in other compilation units and/or those where compiler can not
> + easilly prove fact, that functions is not infinite and thus call to it can be removed

This formulation is a bit obscure.

-- Gaby


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