-Wmissing-pure/-Wmissing-const/-Wmissing-nothrow
Gabriel Dos Reis
dosreis@gmail.com
Fri Jul 3 08:33:00 GMT 2009
On Thu, Jul 2, 2009 at 11:16 AM, Jan Hubicka<hubicka@ucw.cz> wrote:
> Hi,
> this patch adds -Wmissing-const/-Wmissing-pure/-Wmissing-nothrow flags
> that makes compiler to warn when it is profitable to decorate function
> prototype by corresponding attributes.. Those I used for decorating
> libstdc++ so they seem quite useful in practice. The main catch is to
> figure out when the attribute is useful, i.e. when the function can be
> called from other compilation unit where body is not known and thus
> compiler can't do the job by itself. This is true for normal externally
> visible functions, but not true for i.e. C++ combdat or keyed inlines.
You need to rework the options. We need to distinguish between
C++ standard syntax, and GCC-specific extensions.
The C++ standard has the notion of 'const' (as cv-qualifier), and
'thow()' (as exception specification). [ When we have an
implementation of constexpr for C++0x, you would have
a notion of 'pure function' a la GCC for a restricted class
of function.] Traditionally, in the C++ world, when a function
is pure, most people think 'virtual pure'. But, you're exactly
talking about any of those. So, I think the options need to
reflect that you'[re inviting people to use GCC-specific attributes.
I suggest something long the line of -Wattributable=foo, where
'foo' is any of the attributes you would want people to use.
I don't particularly like the 'missing' stuff because it suggests that
the program might be wrong or confusing or error prone because of
some missing bits. That is not the case.
-- Gaby
More information about the Gcc-patches
mailing list