[cfe-commits] r147599 - in /cfe/trunk: include/clang/Basic/DiagnosticGroups.td include/clang/Basic/DiagnosticParseKinds.td include/clang/Sema/DeclSpec.h lib/Parse/ParseDecl.cpp test/CXX/basic/basic.link/p9.cpp test/CXX/dcl.dcl/basic.namespace/nam

Chandler Carruth chandlerc at google.com
Thu Jan 5 18:13:04 PST 2012


On Thu, Jan 5, 2012 at 5:38 PM, Richard Smith <richard at metafoo.co.uk> wrote:

> On Thu, January 5, 2012 04:50, Argyrios Kyrtzidis wrote:
> > On Jan 4, 2012, at 8:12 PM, Richard Smith wrote:
> >> Author: rsmith
> >> Date: Wed Jan  4 22:12:21 2012
> >> New Revision: 147599
> >>
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=147599&view=rev
> >> Log:
> >> PR10828: Produce a warning when a no-arguments function is declared in
> block
> >>  scope, when no other indication is provided that the user intended to
> >> declare a function rather than a variable.
> >>
> >> Remove some false positives from the existing 'parentheses
> disambiguated as
> >> a function' warning by suppressing it when the declaration is marked as
> >> 'typedef'
> >> or 'extern'.
> >>
> >> Add a new warning group -Wvexing-parse containing both of these
> warnings.
> >>
> >>
> >> The new warning is enabled by default; despite a number of false
> positives
> >> (and
> >> one bug) in clang's test-suite, I have only found genuine bugs with it
> when
> >> running it over a significant quantity of real C++ code.
> [...]
> > 2) The new warning belongs in the sema, not the parser, because it
> requires
> > semantic checks; consider the following case:
> >
> > void f() { typedef void VOID; VOID gg();  // false positive here.
> > }
>
> r147642. I've also restricted it to class types; I've not seen any
> instances
> of this for non-class types,


FWIW, I have. Especially with templates.


> and they're the types for which we can silently
> miss important RAII actions. I'd be happy to change this behavior if anyone
> has experience or evidence which points in a different direction.
>

I'm inclined to keep it for non-class types. Block-scope function
declarations are *very* rare, and easily clarified through an 'extern'
keyword no? I see no harm in warning on 'int x()', I strongly suspect it
will catch vastly more bugs than intended function declarations. I'll be
suprised if it finds any function declarations....
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120105/df85531b/attachment.html>


More information about the cfe-commits mailing list