PATCH RFA: Permit attributes on labels in C++
Ian Lance Taylor
iant@google.com
Sat Jun 6 20:55:00 GMT 2009
Jason Merrill <jason@redhat.com> writes:
> Ian Lance Taylor wrote:
>> Note that I changed is_late_template_attribute to mark the unused
>> attribute on a label as applying at template instantiation time.
>
> I don't think that's necessary; the change to re-apply attributes in
> tsubst_expr does the trick.
OK, removed.
>> + if (!cp_parser_require (parser, CPP_SEMICOLON, "%<;%>"))
>> + gcc_unreachable ();
>
> This consumes the semicolon as part of the label, which breaks
>
> { label: __attribute ((unused)) ; }
Oh yeah. Thanks for noticing that. I added a test case.
Ran bootstrap and g++ testsuite on i686-unknown-linux-gnu. OK for
mainline?
Ian
gcc/ChangeLog:
2009-06-06 Ian Lance Taylor <iant@google.com>
* doc/extend.texi (Attribute Syntax): Document that C++ labels on
empty statements can now have attributes.
gcc/cp/ChangeLog:
2009-06-06 Ian Lance Taylor <iant@google.com>
* parser.c (cp_parser_label_for_labeled_statement): Support
attribute on labels if immediately followed by semicolon.
* semantics.c (finish_label_stmt): Return new label.
* pt.c (tsubst_expr): Handle attributes for LABEL_EXPR.
gcc/testsuite/ChangeLog:
2009-06-06 Ian Lance Taylor <iant@google.com>
* gcc.dg/Wunused-label-1.c: New test case.
* g++.dg/warn/Wunused-label-1.C: New test case.
* g++.dg/warn/Wunused-label-2.C: New test case.
* g++.dg/warn/Wunused-label-3.C: New test case.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: foo.patch
Type: text/x-patch
Size: 7217 bytes
Desc: C++ attribute unused on labels
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20090606/ef1f09f8/attachment.bin>
More information about the Gcc-patches
mailing list