From: Giovanni Bajo Date: Tue, 9 Mar 2004 16:23:45 +0000 (+0000) Subject: re PR c++/14409 (Accepts invalid function signature for explicit instantiation) X-Git-Tag: releases/gcc-3.3.4~184 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f81c030e4ebd22c3d5e2bb25b18aea9b42d63865;p=thirdparty%2Fgcc.git re PR c++/14409 (Accepts invalid function signature for explicit instantiation) PR c++/14409 * pt.c (determine_specialization): For member templates, match also constness. PR c++/14409 * g++.dg/template/spec12.C: New test. From-SVN: r79184 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 95cfabcdfd0b..e428b1095832 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2004-03-09 Giovanni Bajo + + PR c++/14409 + * pt.c (determine_specialization): For member templates, match also + constness. + 2004-03-05 Gabriel Dos Reis Backport: diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 154cdcbedd82..0f35b1e356ae 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -1155,6 +1155,7 @@ determine_specialization (template_id, decl, targs_out, if (TREE_CODE (fn) == TEMPLATE_DECL) { tree decl_arg_types; + tree fn_arg_types; /* DECL might be a specialization of FN. */ @@ -1171,8 +1172,16 @@ determine_specialization (template_id, decl, targs_out, The specialization f is invalid but is not caught by get_bindings below. */ - if (list_length (TYPE_ARG_TYPES (TREE_TYPE (fn))) - != list_length (decl_arg_types)) + fn_arg_types = TYPE_ARG_TYPES (TREE_TYPE (fn)); + if (list_length (fn_arg_types) != list_length (decl_arg_types)) + continue; + + /* For a non-static member function, we need to make sure that + the const qualification is the same. This can be done by + checking the 'this' in the argument list. */ + if (DECL_NONSTATIC_MEMBER_FUNCTION_P (fn) + && !same_type_p (TREE_VALUE (fn_arg_types), + TREE_VALUE (decl_arg_types))) continue; /* See whether this function might be a specialization of this diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2ce064ab6ab0..2a4e5657edbc 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2004-03-09 Giovanni Bajo + + PR c++/14409 + * g++.dg/template/spec12.C: New test. + 2004-03-06 Ulrich Weigand * gcc.dg/20040306-1.c: New test.