This fixes the remaining regressions. With the new design for check_global_declaration*(), we diagnose many more warnings and so far, no false positives.

Committed to branch.
commit 7aeb35184b29f3c67470b63fcf107b54f075ffd7
Author: Aldy Hernandez <al...@redhat.com>
Date:   Wed Apr 29 09:43:48 2015 -0700

    Adjust tests with defined/used warnings.

diff --git a/gcc/objc/objc-gnu-runtime-abi-01.c 
b/gcc/objc/objc-gnu-runtime-abi-01.c
index b096fb9..cdf77b2 100644
--- a/gcc/objc/objc-gnu-runtime-abi-01.c
+++ b/gcc/objc/objc-gnu-runtime-abi-01.c
@@ -500,6 +500,8 @@ build_selector_table_decl (void)
   temp = build_array_type (objc_selector_template, NULL_TREE);
 
   UOBJC_SELECTOR_TABLE_decl = start_var_decl (temp, "_OBJC_SELECTOR_TABLE");
+  /* Squash `defined but not used' warning check_global_declaration.  */
+  TREE_USED (UOBJC_SELECTOR_TABLE_decl) = 1;
   OBJCMETA (UOBJC_SELECTOR_TABLE_decl, objc_meta, meta_base);
 }
 
diff --git a/gcc/testsuite/g++.dg/torture/pr46383.C 
b/gcc/testsuite/g++.dg/torture/pr46383.C
index 2b61039..e4810c5 100644
--- a/gcc/testsuite/g++.dg/torture/pr46383.C
+++ b/gcc/testsuite/g++.dg/torture/pr46383.C
@@ -69,9 +69,9 @@ template < class Tr, class Derived, class Element, class 
Previous, class Triangu
   Mesher_level(Previous_level& previous)
     : previous_level(previous)
   { }
-  Vertex_handle insert(Point p, Zone& z) ;
-  Zone conflicts_zone(const Point& p, Element e) ;
-  Element get_next_element() ;
+  Vertex_handle insert(Point p, Zone& z) ; // { dg-warning "used but never 
defined" }
+  Zone conflicts_zone(const Point& p, Element e) ; // { dg-warning "used but 
never defined" }
+  Element get_next_element() ; // { dg-warning "used but never defined" }
   template <class Mesh_visitor> void before_insertion(Element& e, const Point& 
p, Zone& zone, Mesh_visitor visitor) {
     visitor.before_insertion(e, p, zone);
   }
@@ -171,7 +171,7 @@ template <typename Tr> struct 
Triangulation_mesher_level_traits_3
       tr.is_infinite(f) ;
       new_facet<false>(f);
     }
-    template <bool remove_from_complex_if_not_in_restricted_Delaunay> void 
new_facet (const Facet& f) ;
+    template <bool remove_from_complex_if_not_in_restricted_Delaunay> void 
new_facet (const Facet& f) ; // { dg-warning "used but never defined" }
     void after_insertion_handle_opposite_facet (const Facet& f) {
       after_insertion_handle_incident_facet (f);
     }
diff --git a/gcc/testsuite/gfortran.dg/intent_out_8.f90 
b/gcc/testsuite/gfortran.dg/intent_out_8.f90
index 674d833..6360314 100644
--- a/gcc/testsuite/gfortran.dg/intent_out_8.f90
+++ b/gcc/testsuite/gfortran.dg/intent_out_8.f90
@@ -10,7 +10,7 @@ end type t
 
 contains
 
-  subroutine foo(x)
+  subroutine foo(x)             ! { dg-warning "defined but not used" }
     type(t), intent(out) :: x
   end subroutine
 
diff --git a/gcc/testsuite/gfortran.dg/warn_target_lifetime_3.f90 
b/gcc/testsuite/gfortran.dg/warn_target_lifetime_3.f90
index 9113a88..749f987 100644
--- a/gcc/testsuite/gfortran.dg/warn_target_lifetime_3.f90
+++ b/gcc/testsuite/gfortran.dg/warn_target_lifetime_3.f90
@@ -10,7 +10,7 @@ subroutine test
   integer, target :: t
   p => t
 contains
-  subroutine sub()
+  subroutine sub()             ! { dg-warning "defined but not used" }
     if (p /= 0) return
   end subroutine
 end subroutine
@@ -22,7 +22,7 @@ contains
     integer, target :: t2
     p2 => t2 ! { dg-warning "Pointer at .1. in pointer assignment might 
outlive the pointer target" }
   contains
-    subroutine sub()
+    subroutine sub()             ! { dg-warning "defined but not used" }
       if (p2 /= 0) return
     end subroutine
   end subroutine
diff --git a/gcc/toplev.c b/gcc/toplev.c
index 43e1577..3155595 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -505,6 +505,8 @@ wrapup_global_declarations (tree *vec, int len)
 void
 check_global_declaration (tree decl)
 {
+  // ?? Perhaps we should avoid all DECL_ARTIFICIALs here?
+
   /* Warn about any function declared static but not defined.  We don't
      warn about variables, because many programs have static variables
      that exist only to get some text into the object file.  */

Reply via email to