re PR c++/21592 (ICE in resolve_overloaded_unification/arg_assoc)
authorNathan Sidwell <nathan@codesourcery.com>
Wed, 12 Oct 2005 18:13:41 +0000 (18:13 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Wed, 12 Oct 2005 18:13:41 +0000 (18:13 +0000)
cp:
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.

From-SVN: r105313

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 d6dad42f712e28916c462343f1df13ccdfbd7389..404c7de9943dfa0107e3ab9121ea72a57c68482b 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 020d819488a6962f59429c53be610e06a71968a8..6724cf49b2e6d74a5cb74cb1093eaf94aaea3f4f 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 d8210f1394b5eefb8e9ddbb7b5324d35beca156c..d39b53ae967b2c1583979446bd8a644db94cbc7e 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 1f416b691327355833e93c147d0f60b35800d964..9c14e0d2173a8425256ca46b5ccca8e89b3810a4 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 e29b76d42d0699623513b8c4641b52d033f5e249..79649861ba47e3107b324d03029c46c8ba996333 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 9c9d5f96673ed2b015bfd725636acef8f71cd222..06f056b4140ecb3e942ea3d826cbe27d42d42ba9 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" "" }
+}