From ca79f85d9db6e768bfa918ea4d490692ff996c41 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Tue, 2 Sep 1997 16:27:13 -0400 Subject: [PATCH] pt.c (unify): float doesn't match double. * pt.c (unify): float doesn't match double. * pt.c (do_type_instantiation): Handle getting a _TYPE or a TYPE_DECL. Handle getting non-template types. * parse.y (explicit_instantiation): Use typespec instead of aggr template_type. Tue Sep 2 10:27:08 1997 Richard Henderson * typeck.c (build_ptrmemfunc1): Clean up ptr->int cast warnings. From-SVN: r15037 --- gcc/cp/ChangeLog | 13 +++++++++++++ gcc/cp/parse.y | 10 ++++++---- gcc/cp/pt.c | 18 +++++++++++++++--- gcc/cp/typeck.c | 4 ++-- 4 files changed, 36 insertions(+), 9 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 46ede9667c4..fc5a66b51ec 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,16 @@ +Tue Sep 2 12:09:13 1997 Jason Merrill + + * pt.c (unify): float doesn't match double. + + * pt.c (do_type_instantiation): Handle getting a _TYPE or a + TYPE_DECL. Handle getting non-template types. + * parse.y (explicit_instantiation): Use typespec instead of + aggr template_type. + +Tue Sep 2 10:27:08 1997 Richard Henderson + + * typeck.c (build_ptrmemfunc1): Clean up ptr->int cast warnings. + Mon Sep 1 13:19:04 1997 Jason Merrill * call.c (build_new_op): Strip leading REF_BIND from first operand diff --git a/gcc/cp/parse.y b/gcc/cp/parse.y index 4eb8a20eb78..47302a0cc57 100644 --- a/gcc/cp/parse.y +++ b/gcc/cp/parse.y @@ -814,8 +814,9 @@ identifier_defn: ; explicit_instantiation: - TEMPLATE aggr template_type - { do_type_instantiation ($3, NULL_TREE); } + TEMPLATE typespec ';' + { do_type_instantiation ($2.t, NULL_TREE); + yyungetc (';', 1); } | TEMPLATE typed_declspecs declarator { tree specs = strip_attrs ($2.t); do_decl_instantiation (specs, $3, NULL_TREE); } @@ -823,8 +824,9 @@ explicit_instantiation: { do_decl_instantiation (NULL_TREE, $2, NULL_TREE); } | TEMPLATE constructor_declarator { do_decl_instantiation (NULL_TREE, $2, NULL_TREE); } - | SCSPEC TEMPLATE aggr template_type - { do_type_instantiation ($4, $1); } + | SCSPEC TEMPLATE typespec ';' + { do_type_instantiation ($3.t, $1); + yyungetc (';', 1); } | SCSPEC TEMPLATE typed_declspecs declarator { tree specs = strip_attrs ($3.t); do_decl_instantiation (specs, $4, $1); } diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 31007ec84ec..19a85e42cdf 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -2858,6 +2858,10 @@ unify (tparms, targs, ntparms, parm, arg, nsubsts, strict) TYPE_MAX_VALUE (arg), nsubsts, strict)) return 1; } + else if (TREE_CODE (parm) == REAL_TYPE + && TYPE_MAIN_VARIANT (arg) != TYPE_MAIN_VARIANT (parm)) + return 1; + /* As far as unification is concerned, this wins. Later checks will invalidate it if necessary. */ return 0; @@ -3314,14 +3318,22 @@ mark_class_instantiated (t, extern_p) } void -do_type_instantiation (name, storage) - tree name, storage; +do_type_instantiation (t, storage) + tree t, storage; { - tree t = TREE_TYPE (name); int extern_p = 0; int nomem_p = 0; int static_p = 0; + if (TREE_CODE (t) == TYPE_DECL) + t = TREE_TYPE (t); + + if (! IS_AGGR_TYPE (t) || ! CLASSTYPE_TEMPLATE_INFO (t)) + { + cp_error ("explicit instantiation of non-template type `%T'", t); + return; + } + complete_type (t); /* With -fexternal-templates, explicit instantiations are treated the same diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 40f8eef8240..6d2204ce81c 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -6261,14 +6261,14 @@ build_ptrmemfunc1 (type, delta, idx, pfn, delta2) if (pfn) { allconstant = TREE_CONSTANT (pfn); - allsimple = (int) initializer_constant_valid_p (pfn, TREE_TYPE (pfn)); + allsimple = !! initializer_constant_valid_p (pfn, TREE_TYPE (pfn)); u = tree_cons (pfn_field, pfn, NULL_TREE); } else { delta2 = convert_and_check (delta_type_node, delta2); allconstant = TREE_CONSTANT (delta2); - allsimple = (int) initializer_constant_valid_p (delta2, TREE_TYPE (delta2)); + allsimple = !! initializer_constant_valid_p (delta2, TREE_TYPE (delta2)); u = tree_cons (delta2_field, delta2, NULL_TREE); } -- 2.30.2