aboutsummaryrefslogtreecommitdiff
path: root/gcc/expr.c
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2003-09-16 03:58:27 -0400
committerJakub Jelinek <jakub@gcc.gnu.org>2003-09-16 09:58:27 +0200
commit72954a4f4456cbdc8e1ff01e27f488d304ba32ad (patch)
treea6e02ea18c49961a7fc38f54f53192e537f6e3af /gcc/expr.c
parentc9fbef12bee8504ff48a45e3c67099af6772857d (diff)
downloadgcc-72954a4f4456cbdc8e1ff01e27f488d304ba32ad.zip
gcc-72954a4f4456cbdc8e1ff01e27f488d304ba32ad.tar.gz
gcc-72954a4f4456cbdc8e1ff01e27f488d304ba32ad.tar.bz2
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) <case EXPR_WITH_FILE_LOCATION>: 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 <jakub@redhat.com> From-SVN: r71424
Diffstat (limited to 'gcc/expr.c')
-rw-r--r--gcc/expr.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/gcc/expr.c b/gcc/expr.c
index 0538707..584250b 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -235,6 +235,9 @@ enum insn_code movstr_optab[NUM_MACHINE_MODES];
/* This array records the insn_code of insns to perform block clears. */
enum insn_code clrstr_optab[NUM_MACHINE_MODES];
+/* Stack of EXPR_WITH_FILE_LOCATION nested expressions. */
+struct file_stack *expr_wfl_stack;
+
/* SLOW_UNALIGNED_ACCESS is nonzero if unaligned accesses are very slow. */
#ifndef SLOW_UNALIGNED_ACCESS
@@ -6959,14 +6962,23 @@ expand_expr (tree exp, rtx target, enum machine_mode tmode,
case EXPR_WITH_FILE_LOCATION:
{
rtx to_return;
- location_t saved_loc = input_location;
+ struct file_stack fs;
+
+ fs.location = input_location;
+ fs.next = expr_wfl_stack;
input_filename = EXPR_WFL_FILENAME (exp);
input_line = EXPR_WFL_LINENO (exp);
+ expr_wfl_stack = &fs;
if (EXPR_WFL_EMIT_LINE_NOTE (exp))
emit_line_note (input_location);
/* Possibly avoid switching back and forth here. */
- to_return = expand_expr (EXPR_WFL_NODE (exp), target, tmode, modifier);
- input_location = saved_loc;
+ to_return = expand_expr (EXPR_WFL_NODE (exp),
+ (ignore ? const0_rtx : target),
+ tmode, modifier);
+ if (expr_wfl_stack != &fs)
+ abort ();
+ input_location = fs.location;
+ expr_wfl_stack = fs.next;
return to_return;
}