From 43e05e45bcd3092ef7fb02e537ca7645607dbede Mon Sep 17 00:00:00 2001 From: Steven Bosscher Date: Sat, 1 Jan 2005 16:15:23 +0000 Subject: re PR middle-end/17544 (incorrect -Wunreachable-code warning for mains with a return statement) * emit-rtl.c (add_insn_before): Fix comment typo. PR middle-end/17544 * c-decl.c (finish_function): If compiling C99, annotate the compiler generated return with the current file name and line 0. * tree-cfg.c (remove_useless_stmts_warn_notreached): Only warn if the source line is greater than 0. (remove_bb): Likewise. cp/ PR middle-end/17544 * decl.c (finish_function): Fix comment. Annotate the compiler generated return with the current file name and line 0. testsuite/ * gcc.dg/20041231-1.C: New test. * g++.dg/warn/Wunreachable-code-1.C: New test. From-SVN: r92784 --- gcc/c-decl.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'gcc/c-decl.c') diff --git a/gcc/c-decl.c b/gcc/c-decl.c index 2ff015e..a0053ed 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -1,6 +1,6 @@ /* Process declarations and variables for C compiler. Copyright (C) 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, - 2001, 2002, 2003, 2004 Free Software Foundation, Inc. + 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of GCC. @@ -29,6 +29,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include "config.h" #include "system.h" #include "coretypes.h" +#include "input.h" #include "tm.h" #include "intl.h" #include "tree.h" @@ -6287,7 +6288,13 @@ finish_function (void) else { if (flag_isoc99) - c_finish_return (integer_zero_node); + { + tree stmt = c_finish_return (integer_zero_node); + /* Hack. We don't want the middle-end to warn that this + return is unreachable, so put the statement on the + special line 0. */ + annotate_with_file_line (stmt, input_filename, 0); + } } } -- cgit v1.1