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: [PATCH PING] (PR c++/5520) Implement empty-body warning for if() statements


On Thursday 12 January 2006 15:16, Nathan Sidwell wrote:

> I've asked joseph to look at this.  He noticed youve made some other
> changes -- the alloc_stmt_list pieces are removed and you've not mentioned
> the change to c_parser_if_body in the changelog.  The latter's a cleanup,
> but what are the former doing?

They're related. The old code relied on the special NOP marker (which was not 
considered to be an empty statement by IS_EMPTY_STMT) which was then changed 
by the warning into an empty statement list. I'm not sure why the warning did 
that and as I was not sure if it breaks an assertion somewhere in the C++ 
frontend if the warning modifies the tree, so I rather got rid of it. There 
were some funky crashes in the C++ frontend back when I used the code from 
the C frontend: 

add_stmt (build1 (NOP_EXPR, NULL_TREE, NULL_TREE))

Those NULL_TREE's seemed to be evil, and rather than fixing up unknown amount 
of places, the build_empty_stmt() / IS_EMPTY_STMT() approach seemed simpler 
to me. 

There weren't any testsuite regressions because of that and my own testing on 
compilation various sources doesn't seem to uncover a problem. I could strip 
this part, its not strictly necessary. 

Mea culpa for the changelog part, I've now updated it to this: 

2006-01-06  Dirk Mueller <dmueller@suse.com>

        PR c++/5520

        cp/semantics.c (finish_if_stmt): call empty_body_warning
        cp/parser.c (cp_parser_implicitly_scoped_statement):
          mark empty statement with an empty stmt

        c-parser.c (c_parser_if_body): Use build_empty_stmt()
        instead of a special NOP marker.

        c-typeck.c (c_finish_if_stmt): Remove obsoleted special
          NOP marker handling.

        c-common.h (empty_body_warning): add forward declaration.
        c-common.c (empty_body_warning): add (from c_finish_if_stmt).
          Now uses IS_EMPTY_STMT() instead of special NOP markers.

        testsuite/g++.dg/warn/empty-body.C: New

Thanks,

Dirk


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