diff options
author | dodji <dodji@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-04-02 08:51:26 +0000 |
---|---|---|
committer | Andrew Pinski <apinski@cavium.com> | 2012-04-11 14:51:15 -0700 |
commit | 1ba3487ffd9cd14e866ce1e17497b0939328d0e1 (patch) | |
tree | 64b9ac086b1169db561d0f4745d52e0f1910ff4e | |
parent | 459ea1d60dc98abc38ce8146559ebd866e256b8c (diff) | |
download | gcc-1ba3487ffd9cd14e866ce1e17497b0939328d0e1.tar.gz |
PR c++/40942 - Failure of template specialization partial ordering
gcc/cp/
* pt.c (more_specialized_fn): Don't apply decay conversion to
types of function parameters.
gcc/testsuite/
* g++.old-deja/g++.pt/spec40.C: Adjust to take the resolution of
DR 214 in account.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@186067 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/pt.c | 40 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/g++.old-deja/g++.pt/spec40.C | 27 |
4 files changed, 35 insertions, 44 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 06232ea9f98..ea1bd80ed05 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2012-04-02 Dodji Seketeli <dodji@redhat.com> + + PR c++/40942 + * pt.c (more_specialized_fn): Don't apply decay conversion to + types of function parameters. + 2012-04-02 Tristan Gingold <gingold@adacore.com> * ggc-page.c (PAGE_L1_SIZE, PAGE_L2_SIZE, LOOKUP_L1, LOOKUP_L2) diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 9b410a75fd4..04ba37d25e7 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -17132,46 +17132,6 @@ more_specialized_fn (tree pat1, tree pat2, int len) quals2 = cp_type_quals (arg2); } - if ((quals1 < 0) != (quals2 < 0)) - { - /* Only of the args is a reference, see if we should apply - array/function pointer decay to it. This is not part of - DR214, but is, IMHO, consistent with the deduction rules - for the function call itself, and with our earlier - implementation of the underspecified partial ordering - rules. (nathan). */ - if (quals1 >= 0) - { - switch (TREE_CODE (arg1)) - { - case ARRAY_TYPE: - arg1 = TREE_TYPE (arg1); - /* FALLTHROUGH. */ - case FUNCTION_TYPE: - arg1 = build_pointer_type (arg1); - break; - - default: - break; - } - } - else - { - switch (TREE_CODE (arg2)) - { - case ARRAY_TYPE: - arg2 = TREE_TYPE (arg2); - /* FALLTHROUGH. */ - case FUNCTION_TYPE: - arg2 = build_pointer_type (arg2); - break; - - default: - break; - } - } - } - arg1 = TYPE_MAIN_VARIANT (arg1); arg2 = TYPE_MAIN_VARIANT (arg2); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 73f22f3ab4f..bfad9a7b77a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2012-04-02 Dodji Seketeli <dodji@redhat.com> + + PR c++/40942 + * g++.old-deja/g++.pt/spec40.C: Adjust to take the resolution of + DR 214 in account. + 2012-04-01 Paolo Carlini <paolo.carlini@oracle.com> PR c++/50043 diff --git a/gcc/testsuite/g++.old-deja/g++.pt/spec40.C b/gcc/testsuite/g++.old-deja/g++.pt/spec40.C index 70abb6fc50f..fc37f412b7e 100644 --- a/gcc/testsuite/g++.old-deja/g++.pt/spec40.C +++ b/gcc/testsuite/g++.old-deja/g++.pt/spec40.C @@ -1,14 +1,33 @@ -// { dg-do run } +// { dg-do compile } // Copyright (C) 2000 Free Software Foundation, Inc. // Contributed by Nathan Sidwell 12 Feb 2001 <nathan@codesourcery.com> -// More from bug 1617. We didn't resolve partial ordering properly. The -// std is rather vague about it anyway, DR 214 talks about this. +// More from bug 1617. The resolution of DR 214 implies that the below +// call to Foo is ambiguous. +// +// The type transformation (on the function parameter of Foo) allowed +// in the context of partial ordering of the Foo template overloads is +// the following ([temp.deduct.partial]/5): +// +// Before the partial ordering is done, certain transformations +// are performed on the types used for partial ordering: +// +// - If P is a reference type, P is replaced by the type +// referred to. +// +// - If A is a reference type, A is replaced by the type +// referred to. +// +// It follows that we are not allowed to apply array-to-pointer +// decay conversion to the type of the function parameter +// 'char const (&)[I]'. So the two Foo specializations should +// be considered unrelated. Thus the partial ordering of the two +// Foo specializations should fail. template <typename T> int Foo (T const *) {return 1;} template <unsigned I> int Foo (char const (&)[I]) {return 2;} int main () { - return Foo ("a") != 2; + return Foo ("a") != 2; // { dg-error "call of overloaded \[^\n\r\]* is ambiguous" } } |