* [PR90916] ICE in retrieve specialization
@ 2020-01-14 20:29 Nathan Sidwell
2020-01-14 20:45 ` Jason Merrill
0 siblings, 1 reply; 6+ messages in thread
From: Nathan Sidwell @ 2020-01-14 20:29 UTC (permalink / raw)
To: GCC Patches
[-- Attachment #1: Type: text/plain, Size: 744 bytes --]
This fixes an ICE caused by a cleanup of get_class_binding. Previously
its type_or_fn parm defaulted to -1, which had some funky behaviour I
convinced myself was irrelevant to C++ source. Here we're peeking
behind the curtain of a class under construction, and previously the -1
behaviour caused us never to see a type here -- we could only get back
function decls, because we only looked in the method_vector (and that's
only created during construction if there are functions).
so, look at DECL_TEMPLATE_INFO or CLASSTYPE_TEMPLATE_INFO depending on
what we got back. Incidentally, this means we will now optimize member
class instantiations in this case, whereas before we didn't.
Committing to trunk.
nathan
--
Nathan Sidwell
[-- Attachment #2: 90916.diff --]
[-- Type: text/x-patch, Size: 1784 bytes --]
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 004ce0fdcdf..3cc7c48b490 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2020-01-14 Nathan Sidwell <nathan@acm.org>
+
+ PR c++/90916
+ * pt.c (retrieve_specialization): Get the TI from the decl or the
+ classtype as appropriate.
+
2020-01-14 David Malcolm <dmalcolm@redhat.com>
* cp-gimplify.c (source_location_table_entry_hash::empty_zero_p):
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index fa82ecad233..4fdc74f9ca8 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -1252,11 +1252,16 @@ retrieve_specialization (tree tmpl, tree args, hashval_t hash)
for (ovl_iterator iter (fns); iter; ++iter)
{
tree fn = *iter;
- if (DECL_TEMPLATE_INFO (fn) && DECL_TI_TEMPLATE (fn) == tmpl
- /* using-declarations can add base methods to the method vec,
- and we don't want those here. */
- && DECL_CONTEXT (fn) == class_specialization)
- return fn;
+ if (tree ti = (TREE_CODE (fn) == TYPE_DECL && !TYPE_DECL_ALIAS_P (fn)
+ ? TYPE_TEMPLATE_INFO (TREE_TYPE (fn))
+ : DECL_TEMPLATE_INFO (fn)))
+ if (TI_TEMPLATE (ti) == tmpl
+ /* using-declarations can bring in a different
+ instantiation of tmpl as a member of a different
+ instantiation of tmpl's class. We don't want those
+ here. */
+ && DECL_CONTEXT (fn) == class_specialization)
+ return fn;
}
return NULL_TREE;
}
diff --git a/gcc/testsuite/g++.dg/template/pr90916.C b/gcc/testsuite/g++.dg/template/pr90916.C
new file mode 100644
index 00000000000..bdb7e7b58ef
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/pr90916.C
@@ -0,0 +1,8 @@
+// PR c++/90916 ICE in retrieve_specialization
+
+template <typename> struct S
+{
+ struct A;
+ struct f A ();
+};
+template class S <int>;
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PR90916] ICE in retrieve specialization
2020-01-14 20:29 [PR90916] ICE in retrieve specialization Nathan Sidwell
@ 2020-01-14 20:45 ` Jason Merrill
2020-01-14 20:48 ` Nathan Sidwell
0 siblings, 1 reply; 6+ messages in thread
From: Jason Merrill @ 2020-01-14 20:45 UTC (permalink / raw)
To: Nathan Sidwell, GCC Patches
On 1/14/20 2:14 PM, Nathan Sidwell wrote:
> + if (tree ti = (TREE_CODE (fn) == TYPE_DECL && !TYPE_DECL_ALIAS_P (fn)
> + ? TYPE_TEMPLATE_INFO (TREE_TYPE (fn))
> + : DECL_TEMPLATE_INFO (fn)))
Is there a reason not to use get_template_info?
Jason
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PR90916] ICE in retrieve specialization
2020-01-14 20:45 ` Jason Merrill
@ 2020-01-14 20:48 ` Nathan Sidwell
2020-01-14 21:25 ` Nathan Sidwell
0 siblings, 1 reply; 6+ messages in thread
From: Nathan Sidwell @ 2020-01-14 20:48 UTC (permalink / raw)
To: Jason Merrill, GCC Patches
On 1/14/20 3:13 PM, Jason Merrill wrote:
> On 1/14/20 2:14 PM, Nathan Sidwell wrote:
>> +Â Â Â Â Â if (tree ti = (TREE_CODE (fn) == TYPE_DECL &&
>> !TYPE_DECL_ALIAS_P (fn)
>> +Â Â Â Â Â Â Â Â Â Â Â Â ? TYPE_TEMPLATE_INFO (TREE_TYPE (fn))
>> +Â Â Â Â Â Â Â Â Â Â Â Â : DECL_TEMPLATE_INFO (fn)))
>
> Is there a reason not to use get_template_info?
thanks for the pointer, I'll go do that.
nathan
--
Nathan Sidwell
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PR90916] ICE in retrieve specialization
2020-01-14 20:48 ` Nathan Sidwell
@ 2020-01-14 21:25 ` Nathan Sidwell
2020-01-14 21:39 ` Marek Polacek
0 siblings, 1 reply; 6+ messages in thread
From: Nathan Sidwell @ 2020-01-14 21:25 UTC (permalink / raw)
To: Jason Merrill, GCC Patches
[-- Attachment #1: Type: text/plain, Size: 539 bytes --]
On 1/14/20 3:29 PM, Nathan Sidwell wrote:
> On 1/14/20 3:13 PM, Jason Merrill wrote:
>> On 1/14/20 2:14 PM, Nathan Sidwell wrote:
>>> +Â Â Â Â Â if (tree ti = (TREE_CODE (fn) == TYPE_DECL &&
>>> !TYPE_DECL_ALIAS_P (fn)
>>> +Â Â Â Â Â Â Â Â Â Â Â Â ? TYPE_TEMPLATE_INFO (TREE_TYPE (fn))
>>> +Â Â Â Â Â Â Â Â Â Â Â Â : DECL_TEMPLATE_INFO (fn)))
>>
>> Is there a reason not to use get_template_info?
>
> thanks for the pointer, I'll go do that.
Done.
nathan
--
Nathan Sidwell
[-- Attachment #2: 90916-2.diff --]
[-- Type: text/x-patch, Size: 1016 bytes --]
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index c1375398517..59e0994c397 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,9 @@
2020-01-14 Nathan Sidwell <nathan@acm.org>
+ PT c++/90916
+ * pt.c (retrieve_specialization): Use get_template_info, not open
+ coding access.
+
PR c++/90916
* pt.c (retrieve_specialization): Get the TI from the decl or the
classtype as appropriate.
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 7e675ce9039..9bb8cc13e5f 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -1252,9 +1252,7 @@ retrieve_specialization (tree tmpl, tree args, hashval_t hash)
for (ovl_iterator iter (fns); iter; ++iter)
{
tree fn = *iter;
- if (tree ti = (TREE_CODE (fn) == TYPE_DECL && !TYPE_DECL_ALIAS_P (fn)
- ? TYPE_TEMPLATE_INFO (TREE_TYPE (fn))
- : DECL_TEMPLATE_INFO (fn)))
+ if (tree ti = get_template_info (fn))
if (TI_TEMPLATE (ti) == tmpl
/* using-declarations can bring in a different
instantiation of tmpl as a member of a different
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PR90916] ICE in retrieve specialization
2020-01-14 21:25 ` Nathan Sidwell
@ 2020-01-14 21:39 ` Marek Polacek
2020-01-15 12:33 ` Nathan Sidwell
0 siblings, 1 reply; 6+ messages in thread
From: Marek Polacek @ 2020-01-14 21:39 UTC (permalink / raw)
To: Nathan Sidwell; +Cc: Jason Merrill, GCC Patches
On Tue, Jan 14, 2020 at 04:10:07PM -0500, Nathan Sidwell wrote:
> On 1/14/20 3:29 PM, Nathan Sidwell wrote:
> > On 1/14/20 3:13 PM, Jason Merrill wrote:
> > > On 1/14/20 2:14 PM, Nathan Sidwell wrote:
> > > > + if (tree ti = (TREE_CODE (fn) == TYPE_DECL &&
> > > > !TYPE_DECL_ALIAS_P (fn)
> > > > + ? TYPE_TEMPLATE_INFO (TREE_TYPE (fn))
> > > > + : DECL_TEMPLATE_INFO (fn)))
> > >
> > > Is there a reason not to use get_template_info?
> >
> > thanks for the pointer, I'll go do that.
>
> Done.
>
> nathan
> --
> Nathan Sidwell
> diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
> index c1375398517..59e0994c397 100644
> --- a/gcc/cp/ChangeLog
> +++ b/gcc/cp/ChangeLog
> @@ -1,5 +1,9 @@
> 2020-01-14 Nathan Sidwell <nathan@acm.org>
>
> + PT c++/90916
Note this has PT instead of PR :).
Marek
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PR90916] ICE in retrieve specialization
2020-01-14 21:39 ` Marek Polacek
@ 2020-01-15 12:33 ` Nathan Sidwell
0 siblings, 0 replies; 6+ messages in thread
From: Nathan Sidwell @ 2020-01-15 12:33 UTC (permalink / raw)
To: Marek Polacek; +Cc: Jason Merrill, GCC Patches
On 1/14/20 4:21 PM, Marek Polacek wrote:
> On Tue, Jan 14, 2020 at 04:10:07PM -0500, Nathan Sidwell wrote:
>> 2020-01-14 Nathan Sidwell <nathan@acm.org>
>>
>> + PT c++/90916
>
> Note this has PT instead of PR :).
yeah, I caught the typo on the followup. Thanks for noticing!
nathan
--
Nathan Sidwell
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-01-15 12:12 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-14 20:29 [PR90916] ICE in retrieve specialization Nathan Sidwell
2020-01-14 20:45 ` Jason Merrill
2020-01-14 20:48 ` Nathan Sidwell
2020-01-14 21:25 ` Nathan Sidwell
2020-01-14 21:39 ` Marek Polacek
2020-01-15 12:33 ` Nathan Sidwell
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).