* cp-tree.def (TINST_LEVEL): Document TINST_IN_SYSTEM_HEADER_P.
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 8 Apr 2005 19:39:59 +0000 (19:39 +0000)
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 8 Apr 2005 19:39:59 +0000 (19:39 +0000)
* cp-tree.h (struct tinst_level): Add in_system_header_p.
(TINST_IN_SYSTEM_HEADER_P): New macro.
(make_tinst_level): Remove.
* pt.c (lookup_template_class): Preserve DECL_IN_SYSTEM_HEADER on
the instantiated class.
(push_tinst_level): Do not use make_tinst_level.  Set
TINST_IN_SYSTEM_HEADER_P.
(pop_tinst_level): Likewise.
(instantiate_class_template): Set in_system_header.
(instantiate_pending_templates): Likewise.
* tree.c (make_tinst_level): Remove.

PR c++/20145
* g++.dg/warn/Wdtor1.C: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@97854 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/cp-tree.def
gcc/cp/cp-tree.h
gcc/cp/pt.c
gcc/cp/tree.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/warn/Wdtor1.C [new file with mode: 0644]

index e0b452c..145d490 100644 (file)
@@ -1,3 +1,18 @@
+2005-04-08  Mark Mitchell  <mark@codesourcery.com>
+
+       * cp-tree.def (TINST_LEVEL): Document TINST_IN_SYSTEM_HEADER_P.
+       * cp-tree.h (struct tinst_level): Add in_system_header_p.
+       (TINST_IN_SYSTEM_HEADER_P): New macro.
+       (make_tinst_level): Remove.
+       * pt.c (lookup_template_class): Preserve DECL_IN_SYSTEM_HEADER on
+       the instantiated class.
+       (push_tinst_level): Do not use make_tinst_level.  Set
+       TINST_IN_SYSTEM_HEADER_P.
+       (pop_tinst_level): Likewise.
+       (instantiate_class_template): Set in_system_header.
+       (instantiate_pending_templates): Likewise.
+       * tree.c (make_tinst_level): Remove.
+
 2005-04-06  Joseph S. Myers  <joseph@codesourcery.com>
 
        * decl.c (start_decl): Apply pending #pragma weak regardless of
index 00f2aa1..b7c580a 100644 (file)
@@ -289,6 +289,7 @@ DEFTREECODE (TAG_DEFN, "tag_defn", tcc_expression, 0)
 
    TINST_DECL contains the original DECL node.
    TINST_LOCATION contains the location where the template is instantiated.
+   TINST_IN_SYSTEM_HEADER_P is true if the location is in a system header.
 
    A stack of template instantiation nodes is kept through the TREE_CHAIN
    fields of these nodes.  */
index b83b5dc..1f773c0 100644 (file)
@@ -221,6 +221,7 @@ struct tinst_level_s GTY(())
   struct tree_common common;
   tree decl;
   location_t locus;
+  int in_system_header_p;
 };
 typedef struct tinst_level_s * tinst_level_t;
 
@@ -3121,6 +3122,8 @@ typedef enum unification_kind_t {
   (((tinst_level_t) TINST_LEVEL_CHECK (NODE))->decl)
 #define TINST_LOCATION(NODE) \
   (((tinst_level_t) TINST_LEVEL_CHECK (NODE))->locus)
+#define TINST_IN_SYSTEM_HEADER_P(NODE) \
+  (((tinst_level_t) TINST_LEVEL_CHECK (NODE))->in_system_header_p)
 
 /* in class.c */
 
@@ -4244,7 +4247,6 @@ extern tree build_dummy_object                    (tree);
 extern tree maybe_dummy_object                 (tree, tree *);
 extern int is_dummy_object                     (tree);
 extern const struct attribute_spec cxx_attribute_table[];
-extern tree make_tinst_level                    (tree, location_t);
 extern tree make_ptrmem_cst                     (tree, tree);
 extern tree cp_build_type_attribute_variant     (tree, tree);
 extern tree cp_build_qualified_type_real        (tree, int, tsubst_flags_t);
index a6f8ad2..9418df4 100644 (file)
@@ -4609,6 +4609,8 @@ lookup_template_class (tree d1,
        = TREE_PRIVATE (TYPE_STUB_DECL (template_type));
       TREE_PROTECTED (type_decl)
        = TREE_PROTECTED (TYPE_STUB_DECL (template_type));
+      DECL_IN_SYSTEM_HEADER (type_decl)
+       = DECL_IN_SYSTEM_HEADER (template);
 
       /* Set up the template information.  We have to figure out which
         template is the immediate parent if this is a full
@@ -5001,7 +5003,10 @@ push_tinst_level (tree d)
       return 0;
     }
 
-  new = make_tinst_level (d, input_location);
+  new = make_node (TINST_LEVEL);
+  TINST_DECL (new) = d;
+  TINST_LOCATION (new) = input_location;
+  TINST_IN_SYSTEM_HEADER_P (new) = in_system_header;
   TREE_CHAIN (new) = current_tinst_level;
   current_tinst_level = new;
 
@@ -5026,6 +5031,7 @@ pop_tinst_level (void)
   /* Restore the filename and line number stashed away when we started
      this instantiation.  */
   input_location = TINST_LOCATION (old);
+  in_system_header = TINST_IN_SYSTEM_HEADER_P (old);
   current_tinst_level = TREE_CHAIN (old);
   --tinst_depth;
   ++tinst_level_tick;
@@ -5504,7 +5510,9 @@ instantiate_class_template (tree type)
 
   /* Set the input location to the template definition. This is needed
      if tsubsting causes an error.  */
-  input_location = DECL_SOURCE_LOCATION (TYPE_NAME (pattern));
+  typedecl = TYPE_MAIN_DECL (type);
+  input_location = DECL_SOURCE_LOCATION (typedecl);
+  in_system_header = DECL_IN_SYSTEM_HEADER (typedecl);
 
   TYPE_HAS_CONSTRUCTOR (type) = TYPE_HAS_CONSTRUCTOR (pattern);
   TYPE_HAS_NEW_OPERATOR (type) = TYPE_HAS_NEW_OPERATOR (pattern);
@@ -5843,7 +5851,6 @@ instantiate_class_template (tree type)
      the class itself.  This puts error messages involving generated
      implicit functions at a predictable point, and the same point
      that would be used for non-template classes.  */
-  typedecl = TYPE_MAIN_DECL (type);
   input_location = DECL_SOURCE_LOCATION (typedecl);
 
   unreverse_member_declarations (type);
@@ -11590,6 +11597,7 @@ instantiate_pending_templates (int retries)
   tree last = NULL_TREE;
   int reconsider;
   location_t saved_loc = input_location;
+  int saved_in_system_header = in_system_header;
 
   /* Instantiating templates may trigger vtable generation.  This in turn
      may require further template instantiations.  We place a limit here
@@ -11674,6 +11682,7 @@ instantiate_pending_templates (int retries)
   while (reconsider);
 
   input_location = saved_loc;
+  in_system_header = saved_in_system_header;
 }
 
 /* Substitute ARGVEC into T, which is a list of initializers for
index 5d80d59..44315f4 100644 (file)
@@ -1851,17 +1851,6 @@ handle_init_priority_attribute (tree* node,
     }
 }
 
-/* Return a new TINST_LEVEL for DECL at location locus.  */
-tree
-make_tinst_level (tree decl, location_t locus)
-{
-  tree tinst_level = make_node (TINST_LEVEL);
-  TREE_CHAIN (tinst_level) = NULL_TREE;
-  TINST_DECL (tinst_level) = decl;
-  TINST_LOCATION (tinst_level) = locus;
-  return tinst_level;
-}
-
 /* Return a new PTRMEM_CST of the indicated TYPE.  The MEMBER is the
    thing pointed to by the constant.  */
 
index 1eae0ac..3ab4313 100644 (file)
@@ -1,3 +1,8 @@
+2005-04-08  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/20145
+       * g++.dg/warn/Wdtor1.C: New test.
+
 2005-04-06  Francois-Xavier Coudert  <coudert@clipper.ens.fr>
 
        PR fortran/17229
diff --git a/gcc/testsuite/g++.dg/warn/Wdtor1.C b/gcc/testsuite/g++.dg/warn/Wdtor1.C
new file mode 100644 (file)
index 0000000..de1c0e7
--- /dev/null
@@ -0,0 +1,18 @@
+// PR c++/20145
+// { dg-options "-Wnon-virtual-dtor" }
+# 1 "t.cc"
+# 1 "<built-in>"
+# 1 "<command line>"
+# 1 "t.cc"
+# 1 "include/t.h" 1 3 4
+template <int> class t
+{
+  virtual void f();
+};
+# 2 "t.cc" 2
+
+void f(void)
+{
+  t<1> h;
+}
+