From b747e45d26869e4319e236f03143feecbd89b09e Mon Sep 17 00:00:00 2001
From: Per Bothner <per@bothner.com>
Date: Tue, 5 Apr 2005 10:45:32 -0700
Subject: [PATCH] c-decl.c (finish_function): If USE_MAPPED_LOCATION set the
 location of the artification 'return 0' in...

	* c-decl.c (finish_function): If USE_MAPPED_LOCATION set the location
	of the artification 'return 0' in main() to BUILTINS_LOCATION.
	* tree-cfg.c (remove_bb): Check that location isn't BUILTINS_LOCATION
	before warning.

From-SVN: r97641
---
 gcc/ChangeLog  |  7 +++++++
 gcc/c-decl.c   | 12 +++++++++---
 gcc/tree-cfg.c |  2 +-
 3 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 7b44a81f1d15..47ff292efc8b 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2005-04-05  Per Bothner  <per@bothner.com>
+
+	* c-decl.c (finish_function): If USE_MAPPED_LOCATION set the location
+	of the artification 'return 0' in main() to BUILTINS_LOCATION.
+	* tree-cfg.c (remove_bb): Check that location isn't BUILTINS_LOCATION
+	before warning.	
+
 2004-04-05  Devang Patel  <dpatel@apple.com>
 
 	* config/rs600/altivec.md (altivec_vsr<VI_char>): Rename to ..
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index 9d82b9a5b201..100f5a7ad460 100644
--- a/gcc/c-decl.c
+++ b/gcc/c-decl.c
@@ -6272,12 +6272,18 @@ finish_function (void)
 	  if (flag_isoc99)
 	    {
 	      tree stmt = c_finish_return (integer_zero_node);
+#ifdef USE_MAPPED_LOCATION
+	      /* Hack.  We don't want the middle-end to warn that this return
+		 is unreachable, so we mark its location as special.  Using
+		 UNKNOWN_LOCATION has the problem that it gets clobbered in
+		 annotate_one_with_locus.  A cleaner solution might be to
+		 ensure ! should_carry_locus_p (stmt), but that needs a flag.
+	      */
+	      SET_EXPR_LOCATION (stmt, BUILTINS_LOCATION);
+#else
 	      /* Hack.  We don't want the middle-end to warn that this
 		 return is unreachable, so put the statement on the
 		 special line 0.  */
-#ifdef USE_MAPPED_LOCATION
-	      SET_EXPR_LOCATION (stmt, UNKNOWN_LOCATION);
-#else
 	      annotate_with_file_line (stmt, input_filename, 0);
 #endif
 	    }
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index d913759ba8de..00325fc77df5 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -2129,7 +2129,7 @@ remove_bb (basic_block bb)
      loop above, so the last statement we process is the first statement
      in the block.  */
 #ifdef USE_MAPPED_LOCATION
-  if (warn_notreached && loc != UNKNOWN_LOCATION)
+  if (warn_notreached && loc > BUILTINS_LOCATION)
     warning ("%Hwill never be executed", &loc);
 #else
   if (warn_notreached && loc)
-- 
GitLab