OSDN Git Service

PR c++/20669
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 12 May 2010 17:34:55 +0000 (17:34 +0000)
committerMasaki Muranaka <monaka@monami-software.com>
Sun, 23 May 2010 05:06:43 +0000 (14:06 +0900)
* call.c (add_template_candidate_real): If deduction fails, still
add the template as a non-viable candidate.
(equal_functions): Handle template candidates.
(print_z_candidate): Likewise.
(print_z_candidates): Likewise.
(build_new_function_call): Likewise.

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

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/nullptr15.C
gcc/testsuite/g++.dg/template/conv11.C
gcc/testsuite/g++.dg/template/local6.C
libstdc++-v3/ChangeLog
libstdc++-v3/testsuite/20_util/unique_ptr/assign/assign_neg.cc
libstdc++-v3/testsuite/20_util/weak_ptr/comparison/cmp_neg.cc

index 97dcc8d..5f0569a 100644 (file)
@@ -1,5 +1,13 @@
 2010-05-12  Jason Merrill  <jason@redhat.com>
 
+       PR c++/20669
+       * call.c (add_template_candidate_real): If deduction fails, still
+       add the template as a non-viable candidate.
+       (equal_functions): Handle template candidates.
+       (print_z_candidate): Likewise.
+       (print_z_candidates): Likewise.
+       (build_new_function_call): Likewise.
+
        * cp-tree.h (LOOKUP_LIST_ONLY): New.
        * call.c (add_candidates): Enforce it.
        (build_new_method_call): Try non-list ctor if no viable list ctor.
index c618b29..dccb1d4 100644 (file)
@@ -2508,11 +2508,11 @@ add_template_candidate_real (struct z_candidate **candidates, tree tmpl,
                           return_type, strict, flags);
 
   if (i != 0)
-    return NULL;
+    goto fail;
 
   fn = instantiate_template (tmpl, targs, tf_none);
   if (fn == error_mark_node)
-    return NULL;
+    goto fail;
 
   /* In [class.copy]:
 
@@ -2541,7 +2541,7 @@ add_template_candidate_real (struct z_candidate **candidates, tree tmpl,
       tree arg_types = FUNCTION_FIRST_USER_PARMTYPE (fn);
       if (arg_types && same_type_p (TYPE_MAIN_VARIANT (TREE_VALUE (arg_types)),
                                    ctype))
-       return NULL;
+       goto fail;
     }
 
   if (obj != NULL_TREE)
@@ -2575,6 +2575,9 @@ add_template_candidate_real (struct z_candidate **candidates, tree tmpl,
     cand->template_decl = DECL_TEMPLATE_INFO (fn);
 
   return cand;
+ fail:
+  return add_candidate (candidates, tmpl, first_arg, arglist, nargs, NULL,
+                       access_path, conversion_path, 0);
 }
 
 
@@ -2607,10 +2610,10 @@ add_template_conv_candidate (struct z_candidate **candidates, tree tmpl,
 }
 
 /* The CANDS are the set of candidates that were considered for
-   overload resolution.  Return the set of viable candidates.  If none
-   of the candidates were viable, set *ANY_VIABLE_P to true.  STRICT_P
-   is true if a candidate should be considered viable only if it is
-   strictly viable.  */
+   overload resolution.  Return the set of viable candidates, or CANDS
+   if none are viable.  If any of the candidates were viable, set
+   *ANY_VIABLE_P to true.  STRICT_P is true if a candidate should be
+   considered viable only if it is strictly viable.  */
 
 static struct z_candidate*
 splice_viable (struct z_candidate *cands,
@@ -2675,6 +2678,10 @@ build_this (tree obj)
 static inline int
 equal_functions (tree fn1, tree fn2)
 {
+  if (TREE_CODE (fn1) != TREE_CODE (fn2))
+    return 0;
+  if (TREE_CODE (fn1) == TEMPLATE_DECL)
+    return fn1 == fn2;
   if (DECL_LOCAL_FUNCTION_P (fn1) || DECL_LOCAL_FUNCTION_P (fn2)
       || DECL_EXTERN_C_FUNCTION_P (fn1))
     return decls_match (fn1, fn2);
@@ -2710,7 +2717,7 @@ print_z_candidate (const char *msgstr, struct z_candidate *candidate)
     inform (input_location, "%s %T <conversion>", msgstr, candidate->fn);
   else if (candidate->viable == -1)
     inform (input_location, "%s %+#D <near match>", msgstr, candidate->fn);
-  else if (DECL_DELETED_FN (candidate->fn))
+  else if (DECL_DELETED_FN (STRIP_TEMPLATE (candidate->fn)))
     inform (input_location, "%s %+#D <deleted>", msgstr, candidate->fn);
   else
     inform (input_location, "%s %+#D", msgstr, candidate->fn);
@@ -2750,12 +2757,12 @@ print_z_candidates (struct z_candidate *candidates)
     {
       tree fn = cand1->fn;
       /* Skip builtin candidates and conversion functions.  */
-      if (TREE_CODE (fn) != FUNCTION_DECL)
+      if (!DECL_P (fn))
        continue;
       cand2 = &cand1->next;
       while (*cand2)
        {
-         if (TREE_CODE ((*cand2)->fn) == FUNCTION_DECL
+         if (DECL_P ((*cand2)->fn)
              && equal_functions (fn, (*cand2)->fn))
            *cand2 = (*cand2)->next;
          else
@@ -3167,7 +3174,8 @@ build_new_function_call (tree fn, VEC(tree,gc) **args, bool koenig_p,
     {
       if (complain & tf_error)
        {
-         if (!any_viable_p && candidates && ! candidates->next)
+         if (!any_viable_p && candidates && ! candidates->next
+             && (TREE_CODE (candidates->fn) == FUNCTION_DECL))
            return cp_build_function_call_vec (candidates->fn, args, complain);
          if (TREE_CODE (fn) == TEMPLATE_ID_EXPR)
            fn = TREE_OPERAND (fn, 0);
index f0f5c23..a3200c9 100644 (file)
@@ -1,5 +1,69 @@
 2010-05-12  Jason Merrill  <jason@redhat.com>
 
+       * g++.dg/conversion/op1.C: Expect template candidate message.
+       * g++.dg/cpp0x/nullptr15.C: Likewise.
+       * g++.dg/cpp0x/pr31431-2.C: Likewise.
+       * g++.dg/cpp0x/pr31431.C: Likewise.
+       * g++.dg/cpp0x/temp_default2.C: Likewise.
+       * g++.dg/cpp0x/trailing4.C: Likewise.
+       * g++.dg/cpp0x/variadic-ex3.C: Likewise.
+       * g++.dg/cpp0x/variadic-ex4.C: Likewise.
+       * g++.dg/cpp0x/variadic-throw.C: Likewise.
+       * g++.dg/cpp0x/variadic35.C: Likewise.
+       * g++.dg/cpp0x/vt-35147.C: Likewise.
+       * g++.dg/cpp0x/vt-37737-1.C: Likewise.
+       * g++.dg/cpp0x/vt-37737-2.C: Likewise.
+       * g++.dg/ext/visibility/anon8.C: Likewise.
+       * g++.dg/ext/vla2.C: Likewise.
+       * g++.dg/other/pr28114.C: Likewise.
+       * g++.dg/other/ptrmem10.C: Likewise.
+       * g++.dg/other/ptrmem11.C: Likewise.
+       * g++.dg/overload/unknown1.C: Likewise.
+       * g++.dg/parse/template7.C: Likewise.
+       * g++.dg/parse/typename7.C: Likewise.
+       * g++.dg/template/conv11.C: Likewise.
+       * g++.dg/template/copy1.C: Likewise.
+       * g++.dg/template/deduce3.C: Likewise.
+       * g++.dg/template/dependent-expr5.C: Likewise.
+       * g++.dg/template/friend.C: Likewise.
+       * g++.dg/template/incomplete2.C: Likewise.
+       * g++.dg/template/local4.C: Likewise.
+       * g++.dg/template/local6.C: Likewise.
+       * g++.dg/template/operator10.C: Likewise.
+       * g++.dg/template/overload6.C: Likewise.
+       * g++.dg/template/ptrmem2.C: Likewise.
+       * g++.dg/template/ptrmem20.C: Likewise.
+       * g++.dg/template/ptrmem8.C: Likewise.
+       * g++.dg/template/sfinae2.C: Likewise.
+       * g++.dg/template/ttp25.C: Likewise.
+       * g++.dg/template/unify10.C: Likewise.
+       * g++.dg/template/unify11.C: Likewise.
+       * g++.dg/template/unify6.C: Likewise.
+       * g++.dg/template/unify7.C: Likewise.
+       * g++.dg/template/unify9.C: Likewise.
+       * g++.dg/template/varmod1.C: Likewise.
+       * g++.old-deja/g++.brendan/crash56.C: Likewise.
+       * g++.old-deja/g++.law/operators32.C: Likewise.
+       * g++.old-deja/g++.pt/crash28.C: Likewise.
+       * g++.old-deja/g++.pt/crash60.C: Likewise.
+       * g++.old-deja/g++.pt/explicit38.C: Likewise.
+       * g++.old-deja/g++.pt/explicit39.C: Likewise.
+       * g++.old-deja/g++.pt/explicit41.C: Likewise.
+       * g++.old-deja/g++.pt/explicit67.C: Likewise.
+       * g++.old-deja/g++.pt/explicit77.C: Likewise.
+       * g++.old-deja/g++.pt/expr2.C: Likewise.
+       * g++.old-deja/g++.pt/overload7.C: Likewise.
+       * g++.old-deja/g++.pt/ptrmem6.C: Likewise.
+       * g++.old-deja/g++.pt/spec5.C: Likewise.
+       * g++.old-deja/g++.pt/spec6.C: Likewise.
+       * g++.old-deja/g++.pt/t24.C: Likewise.
+       * g++.old-deja/g++.pt/unify4.C: Likewise.
+       * g++.old-deja/g++.pt/unify6.C: Likewise.
+       * g++.old-deja/g++.pt/unify8.C: Likewise.
+       * g++.old-deja/g++.robertl/eb119.C: Likewise.
+       * g++.old-deja/g++.robertl/eb79.C: Likewise.
+       * g++.old-deja/g++.robertl/eb98.C: Likewise.
+
        * g++.dg/cpp0x/initlist32.C: New.
 
        * g++.dg/template/conv11.C: New.
index 4572c53..abb45f4 100644 (file)
@@ -10,7 +10,7 @@ template <typename T, typename U>
 inline typename tType_equal<T, U>::type
 type_equal(U) { }
 
-template<typename T> T* g( T* t );
+template<typename T> T* g( T* t ); // { dg-message "candidate" }
 
 void test_g()
 {
index 846b852..de41d6a 100644 (file)
@@ -1,7 +1,7 @@
 int i;
 struct A
 {
-  template <class T> operator T&() { return i; }
+  template <class T> operator T&() { return i; } // { dg-message "candidate" }
 };
 
 int main()
index 6c5e8ac..1fa39bc 100644 (file)
@@ -1,6 +1,6 @@
-template <class T> struct PCVector2 // { dg-message "candidate is" }
+template <class T> struct PCVector2 // { dg-message "note" }
 {
-    template <class T2> PCVector2(const PCVector2<T> &cv) ;
+    template <class T2> PCVector2(const PCVector2<T> &cv) ; // { dg-message "candidate" }
 
     PCVector2<T> operator- (const PCVector2<T> &ov) const 
        { 
index 903f371..ae20b11 100644 (file)
@@ -1,3 +1,10 @@
+2010-05-12  Jason Merrill  <jason@redhat.com>
+
+       * testsuite/20_util/auto_ptr/assign_neg.cc: Expect template
+       candidate messages.
+       * testsuite/20_util/unique_ptr/assign/assign_neg.cc: Likewise.
+       * testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: Likewise.
+
 2010-05-11  Silvius Rus  <silvius.rus@gmail.com>
 
        PR libstdc++/43259
index 525364b..4aa93b9 100644 (file)
@@ -52,7 +52,8 @@ test03()
 // { dg-error "deleted function" "" { target *-*-* } 357 }
 // { dg-error "used here" "" { target *-*-* } 42 }
 // { dg-error "no matching" "" { target *-*-* } 48 }
-// { dg-warning "candidates are" "" { target *-*-* } 130 }
+// { dg-warning "note" "" { target *-*-* } 130 }
+// { dg-warning "note" "" { target *-*-* } 134 }
 // { dg-warning "note" "" { target *-*-* } 123 }
 // { dg-warning "note" "" { target *-*-* } 118 }
 // { dg-warning "note" "" { target *-*-* } 113 }
index cbe5f9f..6165db0 100644 (file)
@@ -48,4 +48,4 @@ main()
 // { dg-warning "note" "" { target *-*-* } 1005 }
 // { dg-warning "note" "" { target *-*-* } 340 }
 // { dg-warning "note" "" { target *-*-* } 290 }
-// { dg-warning "note" "" { target *-*-* } 201 }
+// { dg-warning "note" "" { target *-*-* } 190 }