public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Dodji Seketeli] Patch PR c++/45200
@ 2010-08-11 18:30 Dodji Seketeli
  2010-08-11 21:04 ` Jason Merrill
  0 siblings, 1 reply; 38+ messages in thread
From: Dodji Seketeli @ 2010-08-11 18:30 UTC (permalink / raw)
  To: GCC Patches; +Cc: Jason Merrill

[-- Attachment #1: Type: text/plain, Size: 64 bytes --]


Sorry, I previously forwarded this to the wrong mailing list.


[-- Attachment #2: Type: message/rfc822, Size: 4012 bytes --]

From: Dodji Seketeli <dodji@redhat.com>
To: Jason Merrill <jason@redhat.com>
Cc: GCC Development <gcc@gcc.gnu.org>
Subject: Patch PR c++/45200
Date: Wed, 11 Aug 2010 15:48:11 +0200
Message-ID: <m3iq3hp8f8.fsf@redhat.com>

Hello,

In the example accompanying the patch below we consider that the
types

     forward_as_lref<typenameseq::seq_type>

at line marked with //#0 and

     forward_as_lref<typename remove_reference<Seq>::type::seq_type>

at the line marked with //#1 should compare equal. And I believe that
is correct[1].

It follows that during the instantiantion of apply<reverse_view>,
lookup_class_template looks up an instantiation for
forward_as_lref<typename remove_reference<Seq>::type::seq_type>
and returns forward_as_lref<typenameseq::seq_type>. Then the
tsubst'ing of forward_as_lref<typenameseq::seq_type> in the
context of template<typename Seq> struct apply fails because it
tries to reuse the typedef seq that was defined in the
incompatible context template<typename Seq, typename N> struct
apply1.

This case seems to argue for stripping typedefs from the
TYPE_CONTEXT of TYPENAME_TYPEs when they are passed as template
arguments. I refrained from doing it before because I thought
that incompatible_dependent_types_p would be enough to handle all
comparisons involving dependent typedefs.

[1]: This is based on the resolution of PR c++/43800 at
http://gcc.gnu.org/ml/gcc-patches/2010-04/msg01241.html

Tested on x86_64-unknown-linux-gnu against trunk and the 4.5
branch. OK to commit to both branches?

commit d9a0f93c1fda1d97cda5747003de84edd3812bda
Author: Dodji Seketeli <dodji@redhat.com>
Date:   Mon Aug 9 23:12:39 2010 +0200

    Fix PR c++/45200

    gcc/cp/Changelog:
    	PR c++/45200
    	* tree.c (strip_typedefs): Strip typedefs from the context of
    	TYPENAME_TYPEs.

    gcc/testsuite/ChangeLog:
    	PR c++/45200
    	* g++.dg/template/typedef34.C: New test.

diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index 450b9e8..6b2aab0 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -1046,6 +1046,11 @@ strip_typedefs (tree t)
 					    TYPE_RAISES_EXCEPTIONS (t));
       }
       break;
+    case TYPENAME_TYPE:
+      result = make_typename_type (strip_typedefs (TYPE_CONTEXT (t)),
+				   TYPENAME_TYPE_FULLNAME (t),
+				   typename_type, tf_none);
+      break;
     default:
       break;
     }
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 484d299..a506053 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -1212,7 +1212,7 @@ incompatible_dependent_types_p (tree t1, tree t2)
 
   if (!t1_typedef_variant_p || !t2_typedef_variant_p)
     /* Either T1 or T2 is not a typedef so we cannot compare the
-       the template parms of the typedefs of T1 and T2.
+       template parms of the typedefs of T1 and T2.
        At this point, if the main variant type of T1 and T2 are equal
        it means the two types can't be incompatible, from the perspective
        of this function.  */
diff --git a/gcc/testsuite/g++.dg/template/typedef34.C b/gcc/testsuite/g++.dg/template/typedef34.C
new file mode 100644
index 0000000..9bb4460
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/typedef34.C
@@ -0,0 +1,37 @@
+// Origin PR c++/45200
+// { dg-do compile }
+
+template<typename T>
+struct remove_reference
+{
+  typedef T type;
+};
+
+template<typename TestType>
+struct forward_as_lref
+{
+};
+
+template<typename Seq, typename N>
+struct apply1
+{
+  typedef typename remove_reference<Seq>::type seq;
+  typedef forward_as_lref<typename seq::seq_type> type; //#0
+};
+
+template<typename Seq>
+struct apply
+{
+  typedef forward_as_lref<typename remove_reference<Seq>::type::seq_type> type; //#1
+};
+
+struct reverse_view
+{
+  typedef int seq_type;
+};
+
+int
+main()
+{
+  apply<reverse_view >::type a2;
+}

-- 
	Dodji

[-- Attachment #3: Type: text/plain, Size: 13 bytes --]



-- 
	Dodji

^ permalink raw reply	[flat|nested] 38+ messages in thread

end of thread, other threads:[~2011-10-28 19:44 UTC | newest]

Thread overview: 38+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-11 18:30 [Dodji Seketeli] Patch PR c++/45200 Dodji Seketeli
2010-08-11 21:04 ` Jason Merrill
2010-08-11 21:06   ` Andrew Pinski
2010-08-12 13:20   ` Dodji Seketeli
2010-08-12 14:35     ` Jason Merrill
2010-08-13 10:30       ` Dodji Seketeli
2010-08-13 15:09         ` Jason Merrill
2010-09-19 22:34       ` Require canonical type comparison for typedefs again. (was Patch PR c++/45200) Dodji Seketeli
2010-09-19 22:47         ` Paolo Carlini
2010-09-20 10:28           ` Require canonical type comparison for typedefs again Dodji Seketeli
2010-09-20 15:35             ` H.J. Lu
2010-09-20 17:07               ` Dodji Seketeli
2010-09-20 21:44                 ` Jason Merrill
2010-09-26 14:44                   ` Dodji Seketeli
2010-09-26 15:10                     ` Jason Merrill
2010-09-28 15:12                       ` Dodji Seketeli
2010-09-28 15:15                         ` Dodji Seketeli
2010-09-28 16:51                         ` Jason Merrill
2010-09-30  8:55                           ` Dodji Seketeli
2010-09-30  9:10                             ` Jason Merrill
2010-10-06 18:53                               ` Dodji Seketeli
2010-10-06 22:15                                 ` Paolo Carlini
2010-10-15 16:09                                   ` Dodji Seketeli
2010-10-20 15:43                                     ` Jason Merrill
2010-10-20 21:10                                       ` Dodji Seketeli
2010-10-20 21:21                                         ` Jason Merrill
2010-10-20 22:06                                           ` Dodji Seketeli
2010-10-21  1:06                                             ` Jason Merrill
2010-10-23 22:46                                               ` Dodji Seketeli
2010-10-23 23:39                                                 ` Jason Merrill
2010-10-24  2:33                                                   ` Dodji Seketeli
2010-10-24  3:03                                                     ` Jason Merrill
2010-10-25 11:52                                                       ` Dodji Seketeli
2010-10-27 15:59                                                         ` Dodji Seketeli
2010-10-28 17:54                                                           ` Jason Merrill
2010-12-17 20:51                                                           ` H.J. Lu
2011-10-28 21:47                                                             ` H.J. Lu
2010-10-07 18:30                                 ` Jason Merrill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).