From 72954a4f4456cbdc8e1ff01e27f488d304ba32ad Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Tue, 16 Sep 2003 03:58:27 -0400 Subject: c-common.c (handle_warn_unused_result_attribute): New function. * c-common.c (handle_warn_unused_result_attribute): New function. (c_common_attribute_table): Add warn_unused_result. (c_expand_expr): Issue warning when result of inlined function with warn_unused_result attribute is ignored. * calls.c (expand_call): Issue warning when result of function with warn_unused_result attribute is ignored. * c-common.h (STMT_EXPR_WARN_UNUSED_RESULT): Define. * expr.c (expr_wfl_stack): Define. (expand_expr) : If ignore, pass const0_rtx as target. Chain locations into expr_wfl_stack. * tree-inline.c (expand_call_inline): Set STMT_EXPR_WARN_UNUSED_RESULT bit if inlined function has warn_unused_result attribute. * input.h (expr_wfl_stack): Declare. * doc/extend.texi: Document warn_unused_result attribute. * gcc.dg/attr-warn-unused-result.c: New test. Co-Authored-By: Jakub Jelinek From-SVN: r71424 --- gcc/c-common.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'gcc/c-common.h') diff --git a/gcc/c-common.h b/gcc/c-common.h index d9cbb2c..0bbc955 100644 --- a/gcc/c-common.h +++ b/gcc/c-common.h @@ -40,6 +40,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA 2: STMT_LINENO_FOR_FN_P (in _STMT) 3: SCOPE_NO_CLEANUPS_P (in SCOPE_STMT) COMPOUND_STMT_BODY_BLOCK (in COMPOUND_STMT) + STMT_EXPR_WARN_UNUSED_RESULT (in STMT_EXPR) 4: SCOPE_PARTIAL_P (in SCOPE_STMT) */ @@ -1054,6 +1055,11 @@ extern void finish_file (void); #define STMT_EXPR_NO_SCOPE(NODE) \ TREE_LANG_FLAG_0 (STMT_EXPR_CHECK (NODE)) +/* Nonzero if this statement-expression should cause warning if its result + is not used. */ +#define STMT_EXPR_WARN_UNUSED_RESULT(NODE) \ + TREE_LANG_FLAG_3 (STMT_EXPR_CHECK (NODE)) + /* LABEL_STMT accessor. This gives access to the label associated with the given label statement. */ #define LABEL_STMT_LABEL(NODE) TREE_OPERAND (LABEL_STMT_CHECK (NODE), 0) -- cgit v1.1