]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/14409 (Accepts invalid function signature for explicit instantiation)
authorGiovanni Bajo <giovannibajo@gcc.gnu.org>
Tue, 9 Mar 2004 16:23:45 +0000 (16:23 +0000)
committerGiovanni Bajo <giovannibajo@gcc.gnu.org>
Tue, 9 Mar 2004 16:23:45 +0000 (16:23 +0000)
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

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog

index 95cfabcdfd0b47206f28dddd7bddb94036fe3569..e428b109583205a981cafad53cf588cf6a4f8860 100644 (file)
@@ -1,3 +1,9 @@
+2004-03-09  Giovanni Bajo  <giovannibajo@gcc.gnu.org>
+
+       PR c++/14409
+       * pt.c (determine_specialization): For member templates, match also
+       constness.
+
 2004-03-05  Gabriel Dos Reis  <gdr@integrable-solutions.net>
 
        Backport:
index 154cdcbedd8254d5608f6f0c95c5313dcae2a98d..0f35b1e356ae8dc01243b09890027abd86397647 100644 (file)
@@ -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<int> 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
index 2ce064ab6ab0f05287194959875590a65bde7da2..2a4e5657edbc063e8d67b5c2316c1b946880eb1d 100644 (file)
@@ -1,3 +1,8 @@
+2004-03-09  Giovanni Bajo  <giovannibajo@gcc.gnu.org>
+
+       PR c++/14409
+       * g++.dg/template/spec12.C: New test.
+
 2004-03-06  Ulrich Weigand  <uweigand@de.ibm.com>
 
        * gcc.dg/20040306-1.c: New test.