* C++ PATCH for c++/70067 (ICE with typename typedef)
@ 2016-03-04 16:06 Jason Merrill
2016-03-04 19:43 ` H.J. Lu
0 siblings, 1 reply; 4+ messages in thread
From: Jason Merrill @ 2016-03-04 16:06 UTC (permalink / raw)
To: gcc-patches List
[-- Attachment #1: Type: text/plain, Size: 281 bytes --]
On this testcase, when strip_typedefs rebuilds a TYPENAME_TYPE to remove
the typedef, in this case it looks up the same typedef and we then abort
because we still have a typedef. In that case, strip the typedef
explicitly.
Tested x86_64-pc-linux-gnu, applying to trunk and 5.
[-- Attachment #2: 70067.patch --]
[-- Type: text/x-patch, Size: 1213 bytes --]
commit 3f1401348184108dd03d3b0d76e51d5166ca95bf
Author: Jason Merrill <jason@redhat.com>
Date: Thu Mar 3 22:40:40 2016 -0500
PR c++/70067
* tree.c (strip_typedefs): Handle TYPENAME_TYPE lookup finding the
same type.
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index 0b7b144..aaf9a4f 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -1437,6 +1437,9 @@ strip_typedefs (tree t, bool *remove_attributes)
result = make_typename_type (strip_typedefs (TYPE_CONTEXT (t),
remove_attributes),
fullname, typename_type, tf_none);
+ /* Handle 'typedef typename A::N N;' */
+ if (typedef_variant_p (result))
+ result = TYPE_MAIN_VARIANT (DECL_ORIGINAL_TYPE (TYPE_NAME (result)));
}
break;
case DECLTYPE_TYPE:
diff --git a/gcc/testsuite/g++.dg/template/typename21.C b/gcc/testsuite/g++.dg/template/typename21.C
new file mode 100644
index 0000000..e5e59b1
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/typename21.C
@@ -0,0 +1,11 @@
+// PR c++/70067
+// { dg-do compile { target c++98 } }
+
+template <class> struct A;
+template <class T> struct B { struct N { }; };
+template <class T> struct D: B<T> {
+ typedef typename D::N N;
+ A<N> *a;
+};
+
+D<int> d;
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: C++ PATCH for c++/70067 (ICE with typename typedef)
2016-03-04 16:06 C++ PATCH for c++/70067 (ICE with typename typedef) Jason Merrill
@ 2016-03-04 19:43 ` H.J. Lu
2016-03-04 19:47 ` Jason Merrill
0 siblings, 1 reply; 4+ messages in thread
From: H.J. Lu @ 2016-03-04 19:43 UTC (permalink / raw)
To: Jason Merrill; +Cc: gcc-patches List
On Fri, Mar 4, 2016 at 8:06 AM, Jason Merrill <jason@redhat.com> wrote:
> On this testcase, when strip_typedefs rebuilds a TYPENAME_TYPE to remove the
> typedef, in this case it looks up the same typedef and we then abort because
> we still have a typedef. In that case, strip the typedef explicitly.
>
> Tested x86_64-pc-linux-gnu, applying to trunk and 5.
I checked this into trunk for:
ERROR: g++.dg/template/typename21.C -std=c++11: syntax error in
target selector "target c++98" for " dg-do 2 compile { target c++98 }
"
ERROR: g++.dg/template/typename21.C -std=c++14: syntax error in
target selector "target c++98" for " dg-do 2 compile { target c++98 }
"
ERROR: g++.dg/template/typename21.C -std=c++98: syntax error in
target selector "target c++98" for " dg-do 2 compile { target c++98 }
"
Will backport to 5 if needed.
--
H.J.
Index: ChangeLog
===================================================================
--- ChangeLog (revision 233974)
+++ ChangeLog (working copy)
@@ -1,3 +1,7 @@
+2016-03-04 H.J. Lu <hongjiu.lu@intel.com>
+
+ * g++.dg/template/typename21.C: Replace c++98 with c++98_only.
+
2016-03-04 David Malcolm <dmalcolm@redhat.com>
PR c/68187
Index: g++.dg/template/typename21.C
===================================================================
--- g++.dg/template/typename21.C (revision 233974)
+++ g++.dg/template/typename21.C (working copy)
@@ -1,5 +1,5 @@
// PR c++/70067
-// { dg-do compile { target c++98 } }
+// { dg-do compile { target c++98_only } }
template <class> struct A;
template <class T> struct B { struct N { }; };
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: C++ PATCH for c++/70067 (ICE with typename typedef)
2016-03-04 19:43 ` H.J. Lu
@ 2016-03-04 19:47 ` Jason Merrill
2016-03-04 19:54 ` H.J. Lu
0 siblings, 1 reply; 4+ messages in thread
From: Jason Merrill @ 2016-03-04 19:47 UTC (permalink / raw)
To: H.J. Lu; +Cc: gcc-patches List
c++98_only is wrong, we should just remove the target specifier.
Jason
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: C++ PATCH for c++/70067 (ICE with typename typedef)
2016-03-04 19:47 ` Jason Merrill
@ 2016-03-04 19:54 ` H.J. Lu
0 siblings, 0 replies; 4+ messages in thread
From: H.J. Lu @ 2016-03-04 19:54 UTC (permalink / raw)
To: Jason Merrill; +Cc: gcc-patches List
On Fri, Mar 4, 2016 at 11:47 AM, Jason Merrill <jason@redhat.com> wrote:
> c++98_only is wrong, we should just remove the target specifier.
>
> Jason
Tested with trunk and 5. Done.
--
H.J.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-03-04 19:54 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-04 16:06 C++ PATCH for c++/70067 (ICE with typename typedef) Jason Merrill
2016-03-04 19:43 ` H.J. Lu
2016-03-04 19:47 ` Jason Merrill
2016-03-04 19:54 ` H.J. Lu
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).