cp:
authornathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 12 Oct 2005 18:13:41 +0000 (18:13 +0000)
committernathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 12 Oct 2005 18:13:41 +0000 (18:13 +0000)
PR c++/21592
* pt.c (build_non_dependent_expr): Don't wrap a COMPONENT_REF
with already looked up member functions.  Assert we're not
returning a NON_DEPENDENT_EXPR with unknown type.
* typeck.c (finish_class_member_access_expr):  We can get
non-template-id-expr baselinks.  If the lookup finds a baselink,
remember it even inside templates.
testsuite:
PR c++/21592
* g++.dg/template/dependent-expr1.C: Add new expected error.
* g++.dg/template/dependent-expr2.C: Adjust error text.
* g++.dg/template/overload6.C: New.

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

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/cp/typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/dependent-expr1.C
gcc/testsuite/g++.dg/template/dependent-expr2.C
gcc/testsuite/g++.dg/template/overload6.C [new file with mode: 0644]

index d6dad42..404c7de 100644 (file)
@@ -1,5 +1,13 @@
 2005-10-12  Nathan Sidwell  <nathan@codesourcery.com>
 
+       PR c++/21592
+       * pt.c (build_non_dependent_expr): Don't wrap a COMPONENT_REF
+       with already looked up member functions.  Assert we're not
+       returning a NON_DEPENDENT_EXPR with unknown type.
+       * typeck.c (finish_class_member_access_expr):  We can get
+       non-template-id-expr baselinks.  If the lookup finds a baselink,
+       remember it even inside templates.
+
        PR c++/23797
        * parser.c (cp_parser_functional_cast): Cope when TYPE is not a
        TYPE_DECL.  Use dependent_type_p to check type.
index 020d819..6724cf4 100644 (file)
@@ -12641,7 +12641,9 @@ build_non_dependent_expr (tree expr)
   /* Preserve OVERLOADs; the functions must be available to resolve
      types.  */
   inner_expr = (TREE_CODE (expr) == ADDR_EXPR ?
-               TREE_OPERAND (expr, 0) : expr);
+               TREE_OPERAND (expr, 0) :
+               TREE_CODE (expr) == COMPONENT_REF ?
+               TREE_OPERAND (expr, 1) : expr);
   if (is_overloaded_fn (inner_expr)
       || TREE_CODE (inner_expr) == OFFSET_REF)
     return expr;
@@ -12680,6 +12682,9 @@ build_non_dependent_expr (tree expr)
                   TREE_OPERAND (expr, 0),
                   build_non_dependent_expr (TREE_OPERAND (expr, 1)));
 
+  /* If the type is unknown, it can't really be non-dependent */
+  gcc_assert (TREE_TYPE (expr) != unknown_type_node);
+  
   /* Otherwise, build a NON_DEPENDENT_EXPR.
 
      REFERENCE_TYPEs are not stripped for expressions in templates
index d8210f1..d39b53a 100644 (file)
@@ -1904,11 +1904,8 @@ finish_class_member_access_expr (tree object, tree name)
     }
 
   if (BASELINK_P (name))
-    {
-      /* A member function that has already been looked up.  */
-      gcc_assert (TREE_CODE (BASELINK_FUNCTIONS (name)) == TEMPLATE_ID_EXPR);
-      member = name;
-    }
+    /* A member function that has already been looked up.  */
+    member = name;
   else
     {
       bool is_template_id = false;
@@ -2002,7 +1999,9 @@ finish_class_member_access_expr (tree object, tree name)
                                         /*preserve_reference=*/false);
   if (processing_template_decl && expr != error_mark_node)
     return build_min_non_dep (COMPONENT_REF, expr,
-                             orig_object, orig_name, NULL_TREE);
+                             orig_object,
+                             BASELINK_P (member) ? member : orig_name,
+                             NULL_TREE);
   return expr;
 }
 
index 1f416b6..9c14e0d 100644 (file)
@@ -1,5 +1,10 @@
 2005-10-12  Nathan Sidwell  <nathan@codesourcery.com>
 
+       PR c++/21592
+       * g++.dg/template/dependent-expr1.C: Add new expected error.
+       * g++.dg/template/dependent-expr2.C: Adjust error text.
+       * g++.dg/template/overload6.C: New.
+
        PR c++/23797
        * g++.dg/other/typename8.C: New.
 
index e29b76d..7964986 100644 (file)
@@ -19,7 +19,7 @@ namespace std
     Foo (sizeof (x));
     Foo (__alignof__ (I));
     Foo (__alignof__ (x));
-    Foo (x->~I ());
+    Foo (x->~I ()); // { dg-error "" }
     //    Foo (typeid (I));
     Foo (delete x); // { dg-error "" }
     Foo (delete[] x); // { dg-error "" }
index 9c9d5f9..06f056b 100644 (file)
@@ -18,6 +18,6 @@ struct B
 {
   bool bar(A& a)
   {
-    return a.foo == 0; // { dg-error "insufficient context" "" }
+    return a.foo == 0; // { dg-error "" "" }
   }
 };
diff --git a/gcc/testsuite/g++.dg/template/overload6.C b/gcc/testsuite/g++.dg/template/overload6.C
new file mode 100644 (file)
index 0000000..478b466
--- /dev/null
@@ -0,0 +1,17 @@
+// Copyright (C) 2005 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 12 Oct 2005 <nathan@codesourcery.com>
+
+// PR 21592:ICE
+// Origin:  Volker Reichelt <reichelt@gcc.gnu.org>
+
+template<typename T> void unique(T,T);
+
+struct A
+{
+  int begin();
+};
+
+template<int> void foo()
+{
+  unique(A().begin); // { dg-error "no matching function" "" }
+}