Commit 736b02fd by Kaveh R. Ghazi Committed by Kaveh Ghazi

c-common.c (decl_attributes): Allow applying attribute `unused' on a LABEL_DECL.

        * c-common.c (decl_attributes): Allow applying attribute `unused'
        on a LABEL_DECL.
        * c-parse.in (label): Parse attributes after a label, and call
        `decl_attributes' to handle them.
        * gansidecl.h (ATTRIBUTE_UNUSED_LABEL): Define.
        * genrecog.c (OUTPUT_LABEL, write_tree_1, write_tree): When
        generating labels, mark them with ATTRIBUTE_UNUSED_LABEL.
        * invoke.texi: Note that labels can be marked `unused'.

From-SVN: r24478
parent fbc7f4a2
Mon Jan 4 10:30:33 1999 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* c-common.c (decl_attributes): Allow applying attribute `unused'
on a LABEL_DECL.
* c-parse.in (label): Parse attributes after a label, and call
`decl_attributes' to handle them.
* gansidecl.h (ATTRIBUTE_UNUSED_LABEL): Define.
* genrecog.c (OUTPUT_LABEL, write_tree_1, write_tree): When
generating labels, mark them with ATTRIBUTE_UNUSED_LABEL.
* invoke.texi: Note that labels can be marked `unused'.
Sun Jan 3 23:32:18 PST 1999 Jeff Law (law@cygnus.com) Sun Jan 3 23:32:18 PST 1999 Jeff Law (law@cygnus.com)
* version.c: Bump for snapshot. * version.c: Bump for snapshot.
......
...@@ -521,7 +521,8 @@ decl_attributes (node, attributes, prefix_attributes) ...@@ -521,7 +521,8 @@ decl_attributes (node, attributes, prefix_attributes)
TREE_USED (type) = 1; TREE_USED (type) = 1;
else if (TREE_CODE (decl) == PARM_DECL else if (TREE_CODE (decl) == PARM_DECL
|| TREE_CODE (decl) == VAR_DECL || TREE_CODE (decl) == VAR_DECL
|| TREE_CODE (decl) == FUNCTION_DECL) || TREE_CODE (decl) == FUNCTION_DECL
|| TREE_CODE (decl) == LABEL_DECL)
TREE_USED (decl) = 1; TREE_USED (decl) = 1;
else else
warning ("`%s' attribute ignored", IDENTIFIER_POINTER (name)); warning ("`%s' attribute ignored", IDENTIFIER_POINTER (name));
......
...@@ -2214,12 +2214,15 @@ label: CASE expr_no_commas ':' ...@@ -2214,12 +2214,15 @@ label: CASE expr_no_commas ':'
error_with_decl (duplicate, "this is the first default label"); error_with_decl (duplicate, "this is the first default label");
} }
position_after_white_space (); } position_after_white_space (); }
| identifier ':' | identifier ':' maybe_attribute
{ tree label = define_label (input_filename, lineno, $1); { tree label = define_label (input_filename, lineno, $1);
stmt_count++; stmt_count++;
emit_nop (); emit_nop ();
if (label) if (label)
expand_label (label); {
expand_label (label);
decl_attributes (label, $3, NULL_TREE);
}
position_after_white_space (); } position_after_white_space (); }
; ;
......
...@@ -2019,12 +2019,15 @@ label: CASE expr_no_commas ':' ...@@ -2019,12 +2019,15 @@ label: CASE expr_no_commas ':'
error_with_decl (duplicate, "this is the first default label"); error_with_decl (duplicate, "this is the first default label");
} }
position_after_white_space (); } position_after_white_space (); }
| identifier ':' | identifier ':' maybe_attribute
{ tree label = define_label (input_filename, lineno, $1); { tree label = define_label (input_filename, lineno, $1);
stmt_count++; stmt_count++;
emit_nop (); emit_nop ();
if (label) if (label)
expand_label (label); {
expand_label (label);
decl_attributes (label, $3, NULL_TREE);
}
position_after_white_space (); } position_after_white_space (); }
; ;
......
...@@ -38,6 +38,14 @@ Boston, MA 02111-1307, USA. */ ...@@ -38,6 +38,14 @@ Boston, MA 02111-1307, USA. */
# define __attribute__(x) # define __attribute__(x)
#endif #endif
#ifndef ATTRIBUTE_UNUSED_LABEL
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 92)
# define ATTRIBUTE_UNUSED_LABEL
# else
# define ATTRIBUTE_UNUSED_LABEL ATTRIBUTE_UNUSED
# endif /* GNUC < 2.92 */
#endif /* ATTRIBUTE_UNUSED_LABEL */
#ifndef ATTRIBUTE_UNUSED #ifndef ATTRIBUTE_UNUSED
#define ATTRIBUTE_UNUSED __attribute__ ((__unused__)) #define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
#endif /* ATTRIBUTE_UNUSED */ #endif /* ATTRIBUTE_UNUSED */
......
...@@ -51,6 +51,9 @@ Boston, MA 02111-1307, USA. */ ...@@ -51,6 +51,9 @@ Boston, MA 02111-1307, USA. */
#include "rtl.h" #include "rtl.h"
#include "obstack.h" #include "obstack.h"
#define OUTPUT_LABEL(INDENT_STRING, LABEL_NUMBER) \
printf("%sL%d: ATTRIBUTE_UNUSED_LABEL\n", (INDENT_STRING), (LABEL_NUMBER))
static struct obstack obstack; static struct obstack obstack;
struct obstack *rtl_obstack = &obstack; struct obstack *rtl_obstack = &obstack;
...@@ -1103,7 +1106,7 @@ write_tree_1 (tree, prevpos, afterward, type) ...@@ -1103,7 +1106,7 @@ write_tree_1 (tree, prevpos, afterward, type)
printf ("\n"); printf ("\n");
if (tree && tree->subroutine_number == 0) if (tree && tree->subroutine_number == 0)
{ {
printf (" L%d:\n", tree->number); OUTPUT_LABEL (" ", tree->number);
tree->label_needed = 0; tree->label_needed = 0;
} }
...@@ -1239,7 +1242,7 @@ write_tree_1 (tree, prevpos, afterward, type) ...@@ -1239,7 +1242,7 @@ write_tree_1 (tree, prevpos, afterward, type)
if (p->label_needed && (p->retest_mode || p->retest_code)) if (p->label_needed && (p->retest_mode || p->retest_code))
{ {
printf ("%sL%d:\n", indents[indent - 2], p->number); OUTPUT_LABEL (indents[indent - 2], p->number);
p->label_needed = 0; p->label_needed = 0;
} }
...@@ -1330,7 +1333,7 @@ write_tree_1 (tree, prevpos, afterward, type) ...@@ -1330,7 +1333,7 @@ write_tree_1 (tree, prevpos, afterward, type)
/* Now that most mode and code tests have been done, we can write out /* Now that most mode and code tests have been done, we can write out
a label for an inner node, if we haven't already. */ a label for an inner node, if we haven't already. */
if (p->label_needed) if (p->label_needed)
printf ("%sL%d:\n", indents[indent - 2], p->number); OUTPUT_LABEL (indents[indent - 2], p->number);
inner_indent = indent; inner_indent = indent;
...@@ -1563,7 +1566,7 @@ write_tree (tree, prevpos, afterward, initial, type) ...@@ -1563,7 +1566,7 @@ write_tree (tree, prevpos, afterward, initial, type)
if (! initial && tree->subroutine_number > 0) if (! initial && tree->subroutine_number > 0)
{ {
printf (" L%d:\n", tree->number); OUTPUT_LABEL (" ", tree->number);
if (afterward) if (afterward)
{ {
......
...@@ -1340,7 +1340,7 @@ In order to get a warning about an unused function parameter, you must ...@@ -1340,7 +1340,7 @@ In order to get a warning about an unused function parameter, you must
specify both @samp{-W} and @samp{-Wunused}. specify both @samp{-W} and @samp{-Wunused}.
To suppress this warning for an expression, simply cast it to void. For To suppress this warning for an expression, simply cast it to void. For
unused variables and parameters, use the @samp{unused} attribute unused variables, parameters and labels, use the @samp{unused} attribute
(@pxref{Variable Attributes}). (@pxref{Variable Attributes}).
@item -Wuninitialized @item -Wuninitialized
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -2128,12 +2128,15 @@ label: CASE expr_no_commas ':' ...@@ -2128,12 +2128,15 @@ label: CASE expr_no_commas ':'
error_with_decl (duplicate, "this is the first default label"); error_with_decl (duplicate, "this is the first default label");
} }
position_after_white_space (); } position_after_white_space (); }
| identifier ':' | identifier ':' maybe_attribute
{ tree label = define_label (input_filename, lineno, $1); { tree label = define_label (input_filename, lineno, $1);
stmt_count++; stmt_count++;
emit_nop (); emit_nop ();
if (label) if (label)
expand_label (label); {
expand_label (label);
decl_attributes (label, $3, NULL_TREE);
}
position_after_white_space (); } position_after_white_space (); }
; ;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment