diff options
author | Mark Mitchell <mark@codesourcery.com> | 2005-04-08 19:39:59 +0000 |
---|---|---|
committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 2005-04-08 19:39:59 +0000 |
commit | 12af7ba340f80ef1222034ebe0ce88a4130a0462 (patch) | |
tree | 7269b44542fb5a413a12a9ea81b3d385f85036dc | |
parent | 01d87b6f3da40f38bfda6a538316fb8e6ce9a888 (diff) | |
download | gcc-12af7ba340f80ef1222034ebe0ce88a4130a0462.zip gcc-12af7ba340f80ef1222034ebe0ce88a4130a0462.tar.gz gcc-12af7ba340f80ef1222034ebe0ce88a4130a0462.tar.bz2 |
re PR c++/20145 (template "class has virtual functions ... " is not suppressed with -isystem)
* 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.
PR c++/20145
* g++.dg/warn/Wdtor1.C: New test.
From-SVN: r97854
-rw-r--r-- | gcc/cp/ChangeLog | 15 | ||||
-rw-r--r-- | gcc/cp/cp-tree.def | 1 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 4 | ||||
-rw-r--r-- | gcc/cp/pt.c | 15 | ||||
-rw-r--r-- | gcc/cp/tree.c | 11 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/warn/Wdtor1.C | 18 |
7 files changed, 54 insertions, 15 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index e0b452c..145d490 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -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 diff --git a/gcc/cp/cp-tree.def b/gcc/cp/cp-tree.def index 00f2aa1..b7c580a 100644 --- a/gcc/cp/cp-tree.def +++ b/gcc/cp/cp-tree.def @@ -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. */ diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index b83b5dc..1f773c0 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -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); diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index a6f8ad2..9418df4 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -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 diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 5d80d59..44315f46 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -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. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1eae0ac..3ab4313 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -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 index 0000000..de1c0e7 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wdtor1.C @@ -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; +} + |