PR c++/22621
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 2 Oct 2005 21:58:08 +0000 (21:58 +0000)
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 2 Oct 2005 21:58:08 +0000 (21:58 +0000)
* parser.c (cp_parser_template_argument): Don't turn "T::f" into
"(*this).T::f".
* pt.c (convert_nontype_argument): Remove ??? comment.

PR c++/22621
* g++.dg/template/overload5.C : New test.

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

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/overload5.C [new file with mode: 0644]

index 14fc98f..789fcfb 100644 (file)
@@ -1,5 +1,10 @@
 2005-10-02  Mark Mitchell  <mark@codesourcery.com>
 
+       PR c++/22621
+       * parser.c (cp_parser_template_argument): Don't turn "T::f" into
+       "(*this).T::f".
+       * pt.c (convert_nontype_argument): Remove ??? comment.
+
        PR c++/23840
        * tree.c (lvalue_p1): A VA_ARG_EXPR with class type is an lvalue,
        when class rvalues are lvalues.
index 7284d4b..08af6e2 100644 (file)
@@ -9099,11 +9099,20 @@ cp_parser_template_argument (cp_parser* parser)
              argument = TREE_OPERAND (argument, 0);
            }
 
-         if (qualifying_class)
+         /* If ADDRESS_P, then we use finish_qualified_id_expr so
+            that we get a pointer-to-member, if appropriate.
+            However, if ADDRESS_P is false, we don't want to turn
+            "T::f" into "(*this).T::f".  */
+         if (qualifying_class && address_p)
            argument = finish_qualified_id_expr (qualifying_class,
                                                 argument,
                                                 /*done=*/true,
-                                                address_p);
+                                                /*address_p=*/true);
+         else if (TREE_CODE (argument) == BASELINK)
+           /* We don't need the information about what class was used
+              to name the overloaded functions.  */  
+           argument = BASELINK_FUNCTIONS (argument);
+
          if (TREE_CODE (argument) == VAR_DECL)
            {
              /* A variable without external linkage might still be a
index 1217580..82d569b 100644 (file)
@@ -3613,9 +3613,7 @@ convert_nontype_argument (tree type, tree expr)
   else if (TYPE_PTRFN_P (type))
     {
       /* If the argument is a template-id, we might not have enough
-        context information to decay the pointer.
-        ??? Why static5.C requires decay and subst1.C works fine
-        even without it?  */
+        context information to decay the pointer.  */
       if (!type_unknown_p (expr_type))
        {
          expr = decay_conversion (expr);
index 67105b0..d34c532 100644 (file)
@@ -1,5 +1,8 @@
 2005-10-02  Mark Mitchell  <mark@codesourcery.com>
 
+       PR c++/22621
+       * g++.dg/template/overload5.C : New test.
+
        PR c++/23840
        * g++.dg/expr/stdarg1.C: New test.
 
diff --git a/gcc/testsuite/g++.dg/template/overload5.C b/gcc/testsuite/g++.dg/template/overload5.C
new file mode 100644 (file)
index 0000000..8e520e9
--- /dev/null
@@ -0,0 +1,28 @@
+// PR c++/22621
+
+struct foo {
+    typedef int (*fun)(int);
+
+  static int f(int);    // overload between static & non-static
+    int f();
+
+  static int g(int);    // non-overloaded static
+};
+
+template<foo::fun>
+struct f_obj {
+  // something ..
+};
+
+f_obj<&foo::f> a;   // OK
+f_obj<foo::f>  b;   // OK (note: a and b are of the same type)
+
+int foo::f()
+{
+  f_obj<&foo::f> a;   // OK
+  f_obj<foo::f>  b;   // ERROR: foo::f cannot be a constant expression
+
+  f_obj<&foo::g> c;   // OK
+  f_obj<foo::g>  d;   // OK
+}
+