From: "Jonathan Wakely" <jwakely.gcc@gmail.com>
To: "Manuel López-Ibáñez" <lopezibanez@gmail.com>
Cc: gcc@gcc.gnu.org
Subject: Re: Changes in C++ FE regarding pedwarns to be errors are harmful
Date: Sun, 13 Jan 2008 22:56:00 -0000 [thread overview]
Message-ID: <4348dea50801131454w1dc2b12cv72df41654e2bec09@mail.gmail.com> (raw)
In-Reply-To: <6c33472e0801121928q22765e54ga1707b45e6a6d7a6@mail.gmail.com>
On 13/01/2008, Manuel López-Ibáñez <lopezibanez@gmail.com> wrote:
> On 12/01/2008, Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
> > On 12/01/2008, Manuel López-Ibáñez <lopezibanez@gmail.com> wrote:
> > >
> > > Here is an initial patch implementing some of your proposals. I used
> > > pederror as the name of the function. That is, it is an error unless
> > > fpermissive is given.
> >
> > These errors should be independent of -pedantic* unless the if
> > (pedantic) check is also present in the code, but that's a special
> > case. Have I understood the intention correctly?
>
> Actually, I didn't understand that we wanted to separate fpermissive
> and pedantic-errors completely. (Notice that the internal
> declaration/definition of fpermissive actually mentions pedantic.) But
> I agree with you: they should be unrelated.
I hadn't noticed that in the flag_permissive declaration, thanks for
pointing it out. I think that comment should be changed to refer to
permerrors instead. (I'm not sure about the bit about being ignored
if -pedantic is given ... is that true today?
To summarise, the proposal is
Introduce a new class of diagnostic, permerror, which is an error by
default, but -fpermissive makes it a warning.
Change most C++ FE pedwarns to permerrors
Stop using pedantic-errors by default for the C++ FE and CPP
Since most pedwarns are now permerrors, we still get errors by
default, or warnings with -fpermissive. However, now CPP doesn't have
to use pedantic-errors to align with the C++ FE, so the class of CPP
diagnostics that are causing problems will remain as warnings, as per
GCC 4.2
If you want errors from the preprocessor you can use
-fpedantic-errors, consistent with C.
I think this results in consistent behaviour for the front-end and
preprocessor for both C and C++ (which is the behaviour documented in
the manual.) Most diagnostics will behave equivalently but there are
a few special cases where the C pedwarn semantics are preferable, so
shouldn't be switched to permerrors (most of these cases are only
enabled by -pedantic and give no diagnostic without)
> Your information above was very helpful. But I am still not sure about
> the rest of pedwarns.
for decl.c I'm not so sure which category some of them should be in.
I'll list the ones I think should stay as pedwarns, everything else
should be a permerror (IMHO)
line 3811 check_tag_decl
if (TREE_CODE (declared_type) != UNION_TYPE && pedantic
&& !in_system_header)
pedwarn ("ISO C++ prohibits anonymous structs");
guarded by pedantic, looks like it's allowed as an extension, so leave
as a pedwarn.
This won't change the default behaviour but now when -pedantic is
given this will only be a warning
line 6922 check_static_variable_definition
else if (pedantic && !INTEGRAL_TYPE_P (type))
pedwarn ("ISO C++ forbids initialization of member constant "
"%qD of non-integral type %qT", decl, type);
Extension, guarded by pedantic, leave it as pedwarn
line 7007 compute_array_index_type
/* As an extension we allow zero-sized arrays. We always allow
them in system headers because glibc uses them. */
else if (integer_zerop (size) && pedantic && !in_system_header)
{
if (name)
pedwarn ("ISO C++ forbids zero-size array %qD", name);
else
pedwarn ("ISO C++ forbids zero-size array");
guarded by pedantic, leave as pedwarn
line 7025 compute_array_index_type
else if (pedantic && warn_vla != 0)
{
if (name)
pedwarn ("ISO C++ forbids variable length array %qD", name);
else
pedwarn ("ISO C++ forbids variable length array");
}
GNU extension, guarded by pedantic, leave as pedwarn
7655 grokdeclarator
else if (pedantic || ! is_main)
pedwarn ("ISO C++ forbids declaration of %qs with no type", name);
else
warning (OPT_Wreturn_type,
"ISO C++ forbids declaration of %qs with no type", name);
interesting one, the comment above says:
/* We handle `main' specially here, because 'main () { }' is so
common. With no options, it is allowed. With -Wreturn-type,
it is a warning. It is only an error with -pedantic-errors. */
That's true, but currently pedantic-errors is on by default.
I think this should become:
else if (! is_main)
permerror ("ISO C++ forbids declaration of %qs with no type", name);
else if (pedantic)
pedwarn ("ISO C++ forbids declaration of %qs with no type", name);
else
warning (OPT_Wreturn_type,
"ISO C++ forbids declaration of %qs with no type", name);
That would make it an error anywhere except main, but in main it's a
warning with -pedantic or -Wreturn-type. -pedantic-errors or -Werror
make it an error on main too.
7703 grokdeclarator
pedwarn ("long, short, signed or unsigned used invalidly for %qs",
name);
guarded by pedantic, leave as pedwarn
7808 grokdeclarator
/* This was an error in C++98 (cv-qualifiers cannot be added to
a function type), but DR 295 makes the code well-formed by
dropping the extra qualifiers. */
if (pedantic)
{
tree bad_type = build_qualified_type (type, type_quals);
pedwarn ("ignoring %qV qualifiers added to function type %qT",
bad_type, type);
}
This is currently allowed by default, but an error with -pedantic,
even though it's well-formed! Stay as pedwarn so it's only a warning
with -pedantic
9053 grokdeclarator
guarded by pedantic, leave both as pedwarns
9146 grokdeclarator
guarded by pedantic, leave as pedwarn (but change the one above to permerror)
10013 grok_op_properties
guarded by pedantic, leave as pedwarn
I think all others should change to permerrors.
Jon
next prev parent reply other threads:[~2008-01-13 22:55 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-08 21:27 Ismail Dönmez
2008-01-08 21:34 ` Joe Buck
2008-01-08 21:43 ` Richard Guenther
2008-01-08 21:44 ` Ismail Dönmez
2008-01-08 22:13 ` Andrew Pinski
2008-01-08 22:29 ` Manuel López-Ibáñez
2008-01-08 22:36 ` Ismail Dönmez
2008-01-08 22:45 ` Andrew Pinski
2008-01-09 14:10 ` Paolo Bonzini
2008-01-09 15:38 ` Manuel López-Ibáñez
2008-01-09 15:57 ` Paolo Bonzini
2008-01-08 22:51 ` Manuel López-Ibáñez
2008-01-08 23:02 ` Ismail Dönmez
2008-01-09 1:23 ` Ismail Dönmez
2008-01-09 2:25 ` Manuel López-Ibáñez
2008-01-09 16:47 ` Ian Lance Taylor
2008-01-09 18:11 ` Benjamin Kosnik
2008-01-09 18:18 ` Andrew Pinski
2008-01-09 18:21 ` Paolo Carlini
2008-01-09 19:42 ` Mark Mitchell
2008-01-11 17:06 ` Jason Merrill
2008-01-11 17:12 ` Joe Buck
2008-01-11 17:55 ` Mark Mitchell
2008-01-12 19:07 ` Jonathan Wakely
2008-01-12 19:50 ` Manuel López-Ibáñez
2008-01-13 3:28 ` Jonathan Wakely
2008-01-13 15:30 ` Manuel López-Ibáñez
2008-01-13 22:56 ` Jonathan Wakely [this message]
2008-01-14 2:04 ` Jonathan Wakely
2008-01-14 2:19 ` Manuel López-Ibáñez
2008-01-13 15:33 ` Gabriel Dos Reis
2008-01-13 15:36 ` Ismail Dönmez
2008-01-13 16:09 ` Andreas Schwab
2008-01-13 16:10 ` Ismail Dönmez
2008-01-13 16:13 ` Richard Guenther
2008-01-13 16:41 ` Ismail Dönmez
2008-01-13 23:08 ` Manuel López-Ibáñez
2008-01-14 11:03 ` Paolo Bonzini
2008-01-14 16:23 ` Ismail Dönmez
2008-01-13 16:43 ` Gabriel Dos Reis
2008-01-13 16:45 ` Ismail Dönmez
2008-01-13 19:17 ` Gabriel Dos Reis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4348dea50801131454w1dc2b12cv72df41654e2bec09@mail.gmail.com \
--to=jwakely.gcc@gmail.com \
--cc=gcc@gcc.gnu.org \
--cc=lopezibanez@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).