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: [C++ Patch] One more DECL_SOURCE_LOCATION


On Fri, Oct 11, 2019 at 05:14:33PM +0200, Paolo Carlini wrote:
> Hi,
> 
> On 11/10/19 15:37, Marek Polacek wrote:
> > 
> > > Index: cp/decl.c
> > > ===================================================================
> > > --- cp/decl.c	(revision 276845)
> > > +++ cp/decl.c	(working copy)
> > > @@ -4992,7 +4992,8 @@ check_tag_decl (cp_decl_specifier_seq *declspecs,
> > >         if (TREE_CODE (declared_type) != UNION_TYPE
> > >   	  && !in_system_header_at (input_location))
> > > -	pedwarn (input_location, OPT_Wpedantic, "ISO C++ prohibits anonymous structs");
> > > +	pedwarn (DECL_SOURCE_LOCATION (TYPE_MAIN_DECL (declared_type)),
> > > +		 OPT_Wpedantic, "ISO C++ prohibits anonymous structs");
> > The change looks fine but the in_system_header_at line can be dropped, right?
> 
> What do you mean, exactly? Do you mean that, more correctly, we should use
> DECL_SOURCE_LOCATION for it too or that in fact is and was already
> completely redundant? I agree with the former, I didn't bother changing it
> (likely in a couple of other places too) because in practice input_location
> should work fine anyway as far as noticing that we are in system header is
> concerned and is simpler. If you mean the latter, I'm not sure, I don't
> really see why...

I mean the latter; pedwarn will check for diagnostic_report_warnings_p so
the pedwarn will not trigger in a system header unless -Wsystem-headers
even without that check.

I know you're just changing the location so you don't need to drop it.

I wouldn't worry about the former, I guess it would only make a difference
when the { comes from a system header and the } doesn't.

--
Marek Polacek • Red Hat, Inc. • 300 A St, Boston, MA


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