re PR c++/15875 (rejects pointer to member in template)
authorJason Merrill <jason@redhat.com>
Thu, 10 Jun 2004 18:28:53 +0000 (14:28 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 10 Jun 2004 18:28:53 +0000 (14:28 -0400)
        PR c++/15875
        Revert:
        2004-06-01  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
        * init.c (build_offset_ref): Build SCOPE_REF with non-null
        TREE_TYPE for non-dependent names.
        * pt.c (type_dependent_expression_p): Handle SCOPE_REF with
        unknown_type_node as its TREE_TYPE.
        * cxx-pretty_print.c (pp_cxx_unqualified_id): Handle BASELINK.
        * error.c (dump_decl) <SCOPE_REF case>: Use pp_expression.
        (dump_expr) <SCOPE_REF case>: Likewise.

From-SVN: r82933

gcc/cp/ChangeLog
gcc/cp/cxx-pretty-print.c
gcc/cp/error.c
gcc/cp/init.c
gcc/cp/pt.c
gcc/testsuite/g++.dg/template/non-dependent10.C [deleted file]
gcc/testsuite/g++.dg/template/non-dependent7.C [deleted file]
gcc/testsuite/g++.dg/template/non-dependent8.C [deleted file]
gcc/testsuite/g++.dg/template/non-dependent9.C [deleted file]

index 5f49e4ba24fc21fb0f141482cffeb35424649b8c..278e4d4a2230384a936250955fccd33af1a98d58 100644 (file)
@@ -1,3 +1,16 @@
+2004-06-10  Jason Merrill  <jason@redhat.com>
+
+       PR c++/15875
+       Revert:
+       2004-06-01  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
+       * init.c (build_offset_ref): Build SCOPE_REF with non-null
+       TREE_TYPE for non-dependent names.
+       * pt.c (type_dependent_expression_p): Handle SCOPE_REF with
+       unknown_type_node as its TREE_TYPE.
+       * cxx-pretty_print.c (pp_cxx_unqualified_id): Handle BASELINK.
+       * error.c (dump_decl) <SCOPE_REF case>: Use pp_expression.
+       (dump_expr) <SCOPE_REF case>: Likewise.
+
 2004-06-10  Mark Mitchell  <mark@codesourcery.com>
 
        PR c++/15227
index 328ece0f3327c148a6ac34ad837f4f81c113124e..c5e667d9495f9efbaff808f07c0a5e467558d6e8 100644 (file)
@@ -180,10 +180,6 @@ pp_cxx_unqualified_id (cxx_pretty_printer *pp, tree t)
       pp_cxx_template_id (pp, t);
       break;
 
-    case BASELINK:
-      pp_cxx_unqualified_id (pp, BASELINK_FUNCTIONS (t));
-      break;
-
     case RECORD_TYPE:
     case UNION_TYPE:
     case ENUMERAL_TYPE:
index faa2bfbef0c9c8d8bb8fc06c405f9f15d02a7674..6e186503bad925328ceccb6d533042be94f66248 100644 (file)
@@ -771,7 +771,9 @@ dump_decl (tree t, int flags)
       break;
 
     case SCOPE_REF:
-      pp_expression (cxx_pp, t);
+      dump_decl (TREE_OPERAND (t, 0), flags & ~TFF_DECL_SPECIFIERS);
+      pp_colon_colon (cxx_pp); 
+      dump_decl (TREE_OPERAND (t, 1), flags);
       break;
 
     case ARRAY_REF:
@@ -1697,7 +1699,9 @@ dump_expr (tree t, int flags)
       break;
 
     case SCOPE_REF:
-      pp_expression (cxx_pp, t);
+      dump_type (TREE_OPERAND (t, 0), flags);
+      pp_colon_colon (cxx_pp);
+      dump_expr (TREE_OPERAND (t, 1), flags | TFF_EXPR_IN_PARENS);
       break;
 
     case CAST_EXPR:
index 5f0872e80cdc9b8d6bb37fbf96705471da0594e1..1c003566108f05570478a0f08b264b0b0a4021c9 100644 (file)
@@ -1368,7 +1368,7 @@ build_offset_ref (tree type, tree name, bool address_p)
   if (TREE_CODE (name) == TEMPLATE_DECL)
     return name;
 
-  if (dependent_type_p (type) || type_dependent_expression_p (name))
+  if (processing_template_decl || uses_template_parms (type))
     return build_min_nt (SCOPE_REF, type, name);
 
   if (TREE_CODE (name) == TEMPLATE_ID_EXPR)
@@ -1450,14 +1450,6 @@ build_offset_ref (tree type, tree name, bool address_p)
       return error_mark_node;
     }
 
-  if (processing_template_decl)
-    {
-      if (TREE_CODE (orig_name) == TEMPLATE_ID_EXPR)
-       return build_min (SCOPE_REF, TREE_TYPE (member), type, orig_name);
-      else
-       return build_min (SCOPE_REF, TREE_TYPE (member), type, name);
-    }
-
   if (TREE_CODE (member) == TYPE_DECL)
     {
       TREE_USED (member) = 1;
index fd75f78cd9a5c681cf48d6aa869445b23d553059..ff96eaa83c7eeb04183640caeb07d47ffdb1eb30 100644 (file)
@@ -11913,6 +11913,22 @@ type_dependent_expression_p (tree expression)
        return dependent_type_p (type);
     }
 
+  if (TREE_CODE (expression) == SCOPE_REF
+      && dependent_scope_ref_p (expression,
+                               type_dependent_expression_p))
+    return true;
+
+  if (TREE_CODE (expression) == FUNCTION_DECL
+      && DECL_LANG_SPECIFIC (expression)
+      && DECL_TEMPLATE_INFO (expression)
+      && (any_dependent_template_arguments_p
+         (INNERMOST_TEMPLATE_ARGS (DECL_TI_ARGS (expression)))))
+    return true;
+
+  if (TREE_CODE (expression) == TEMPLATE_DECL
+      && !DECL_TEMPLATE_TEMPLATE_PARM_P (expression))
+    return false;
+
   if (TREE_TYPE (expression) == unknown_type_node)
     {
       if (TREE_CODE (expression) == ADDR_EXPR)
@@ -11926,9 +11942,7 @@ type_dependent_expression_p (tree expression)
          if (TREE_CODE (expression) == IDENTIFIER_NODE)
            return false;
        }
-      if (TREE_CODE (expression) == SCOPE_REF)
-       return false;
-
+      
       if (TREE_CODE (expression) == BASELINK)
        expression = BASELINK_FUNCTIONS (expression);
       if (TREE_CODE (expression) == TEMPLATE_ID_EXPR)
@@ -11951,22 +11965,6 @@ type_dependent_expression_p (tree expression)
       abort ();
     }
   
-  if (TREE_CODE (expression) == SCOPE_REF
-      && dependent_scope_ref_p (expression,
-                               type_dependent_expression_p))
-    return true;
-
-  if (TREE_CODE (expression) == FUNCTION_DECL
-      && DECL_LANG_SPECIFIC (expression)
-      && DECL_TEMPLATE_INFO (expression)
-      && (any_dependent_template_arguments_p
-         (INNERMOST_TEMPLATE_ARGS (DECL_TI_ARGS (expression)))))
-    return true;
-
-  if (TREE_CODE (expression) == TEMPLATE_DECL
-      && !DECL_TEMPLATE_TEMPLATE_PARM_P (expression))
-    return false;
-
   return (dependent_type_p (TREE_TYPE (expression)));
 }
 
diff --git a/gcc/testsuite/g++.dg/template/non-dependent10.C b/gcc/testsuite/g++.dg/template/non-dependent10.C
deleted file mode 100644 (file)
index 369e137..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-// { dg-do compile }
-
-// Origin: Giovanni Bajo <giovannibajo@libero.it>
-
-// Two-phase name lookup for address of member:
-// Detecting error during parsing
-
-struct S
-{
-  char i;
-};
-
-template<int S::*p>
-struct X
-{};
-
-template <class T>
-struct Foo
-{
-  X<&S::i> x;  // { dg-error "convert|no type" }
-};
diff --git a/gcc/testsuite/g++.dg/template/non-dependent7.C b/gcc/testsuite/g++.dg/template/non-dependent7.C
deleted file mode 100644 (file)
index c046312..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-// { dg-do compile }
-
-// Origin: Giovanni Bajo <giovannibajo@libero.it>
-
-// Two-phase name lookup for address of member:
-// Overloading function
-
-struct S
-{
-  int f();
-  int f(int);
-};
-
-template<int (S::*p)()>
-struct X
-{};
-
-template <class T>
-struct Foo
-{
-  X<&S::f> x;
-};
diff --git a/gcc/testsuite/g++.dg/template/non-dependent8.C b/gcc/testsuite/g++.dg/template/non-dependent8.C
deleted file mode 100644 (file)
index 0adac25..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-// { dg-do compile }
-
-// Origin: Giovanni Bajo <giovannibajo@libero.it>
-
-// Two-phase name lookup for address of member:
-// Detecting overloading function error during parsing
-
-struct S
-{
-  int f(char);
-  int f(int);
-};
-
-template<int (S::*p)()>
-struct X
-{};
-
-template <class T>
-struct Foo
-{
-  X<&S::f> x;  // { dg-error "convert|no type" }
-};
diff --git a/gcc/testsuite/g++.dg/template/non-dependent9.C b/gcc/testsuite/g++.dg/template/non-dependent9.C
deleted file mode 100644 (file)
index ee34327..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-// { dg-do compile }
-
-// Origin: Giovanni Bajo <giovannibajo@libero.it>
-
-// PR c++/13092: ICE taking address of member which is non-dependent
-
-struct S
-{
-  int i;
-};
-
-template<int S::*p>
-struct X
-{};
-
-template <class T>
-struct Foo
-{
-  X<&S::i> x;
-};
-
-template struct Foo<void>;