aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-cfg.c
diff options
context:
space:
mode:
authorSteven Bosscher <stevenb@suse.de>2005-01-01 16:15:23 +0000
committerSteven Bosscher <steven@gcc.gnu.org>2005-01-01 16:15:23 +0000
commit43e05e45bcd3092ef7fb02e537ca7645607dbede (patch)
treec6d40e9cbaa9fa337df7a271539a709395f1c913 /gcc/tree-cfg.c
parent8e1d2e8278cc2bed80ad1a1564cee131996b6129 (diff)
downloadgcc-43e05e45bcd3092ef7fb02e537ca7645607dbede.zip
gcc-43e05e45bcd3092ef7fb02e537ca7645607dbede.tar.gz
gcc-43e05e45bcd3092ef7fb02e537ca7645607dbede.tar.bz2
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
Diffstat (limited to 'gcc/tree-cfg.c')
-rw-r--r--gcc/tree-cfg.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index e020676..a68c964 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -1,5 +1,5 @@
/* Control flow functions for trees.
- Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
Contributed by Diego Novillo <dnovillo@redhat.com>
This file is part of GCC.
@@ -1323,8 +1323,11 @@ remove_useless_stmts_warn_notreached (tree stmt)
if (EXPR_HAS_LOCATION (stmt))
{
location_t loc = EXPR_LOCATION (stmt);
- warning ("%Hwill never be executed", &loc);
- return true;
+ if (LOCATION_LINE (loc) > 0)
+ {
+ warning ("%Hwill never be executed", &loc);
+ return true;
+ }
}
switch (TREE_CODE (stmt))
@@ -2021,11 +2024,17 @@ remove_bb (basic_block bb)
since this way we lose warnings for gotos in the original
program that are indeed unreachable. */
if (TREE_CODE (stmt) != GOTO_EXPR && EXPR_HAS_LOCATION (stmt) && !loc)
+ {
+ source_locus t;
+
#ifdef USE_MAPPED_LOCATION
- loc = EXPR_LOCATION (stmt);
+ t = EXPR_LOCATION (stmt);
#else
- loc = EXPR_LOCUS (stmt);
+ t = EXPR_LOCUS (stmt);
#endif
+ if (t && LOCATION_LINE (*t) > 0)
+ loc = t;
+ }
}
/* If requested, give a warning that the first statement in the