* [PATCH] c++: Fix up ICE when cplus_decl_attributes is called with error_mark_node attributes [PR104668]
@ 2022-03-25 16:34 Jakub Jelinek
2022-03-25 18:08 ` Jason Merrill
0 siblings, 1 reply; 7+ messages in thread
From: Jakub Jelinek @ 2022-03-25 16:34 UTC (permalink / raw)
To: Jason Merrill; +Cc: gcc-patches
Hi!
cplus_decl_attributes can be called with attributes equal to
error_mark_node, there are some spots in the function that test
it or decl_attributes it calls starts with:
if (TREE_TYPE (*node) == error_mark_node || attributes == error_mark_node)
return NULL_TREE;
But the recent PR104245 change broke this when processing_template_decl
is true.
This fixes it and also fixes an OpenMP problem with such attributes.
Ok for trunk if it passes bootstrap/regtest?
2022-03-25 Jakub Jelinek <jakub@redhat.com>
PR c++/104668
* decl2.cc (splice_template_attributes): Return NULL if *p is
error_mark_node.
(cplus_decl_attributes): Don't chain on OpenMP attributes if
attributes is error_mark_node.
* g++.dg/cpp0x/pr104668.C: New test.
--- gcc/cp/decl2.cc.jj 2022-03-09 09:09:55.415843331 +0100
+++ gcc/cp/decl2.cc 2022-03-25 17:17:27.769036749 +0100
@@ -1336,7 +1336,7 @@ splice_template_attributes (tree *attr_p
tree late_attrs = NULL_TREE;
tree *q = &late_attrs;
- if (!p)
+ if (!p || *p == error_mark_node)
return NULL_TREE;
for (; *p; )
@@ -1644,6 +1644,8 @@ cplus_decl_attributes (tree *decl, tree
&& DECL_CLASS_SCOPE_P (*decl))
error ("%q+D static data member inside of declare target directive",
*decl);
+ else if (attributes == error_mark_node)
+ ;
else if (VAR_P (*decl)
&& (processing_template_decl
|| !cp_omp_mappable_type (TREE_TYPE (*decl))))
--- gcc/testsuite/g++.dg/cpp0x/pr104668.C.jj 2022-03-25 17:25:42.280068058 +0100
+++ gcc/testsuite/g++.dg/cpp0x/pr104668.C 2022-03-25 17:24:44.862881444 +0100
@@ -0,0 +1,13 @@
+// PR c++/104668
+// { dg-do compile { target c++11 } }
+// { dg-excess-errors "" }
+
+template <class... Ts>
+void sink(Ts...);
+template <class... Ts>
+void f(Ts...) {
+ sink([] { struct alignas:Ts) S {}; }...); }
+}
+int main() {
+ f(0);
+}
Jakub
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] c++: Fix up ICE when cplus_decl_attributes is called with error_mark_node attributes [PR104668]
2022-03-25 16:34 [PATCH] c++: Fix up ICE when cplus_decl_attributes is called with error_mark_node attributes [PR104668] Jakub Jelinek
@ 2022-03-25 18:08 ` Jason Merrill
[not found] ` <Yj4Oe1CHMe1y7wZf@tucnak>
2022-04-06 15:18 ` Jason Merrill
0 siblings, 2 replies; 7+ messages in thread
From: Jason Merrill @ 2022-03-25 18:08 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: gcc-patches
On 3/25/22 12:34, Jakub Jelinek wrote:
> Hi!
>
> cplus_decl_attributes can be called with attributes equal to
> error_mark_node, there are some spots in the function that test
> it or decl_attributes it calls starts with:
> if (TREE_TYPE (*node) == error_mark_node || attributes == error_mark_node)
> return NULL_TREE;
> But the recent PR104245 change broke this when processing_template_decl
> is true.
>
> This fixes it and also fixes an OpenMP problem with such attributes.
>
> Ok for trunk if it passes bootstrap/regtest?
>
> 2022-03-25 Jakub Jelinek <jakub@redhat.com>
>
> PR c++/104668
> * decl2.cc (splice_template_attributes): Return NULL if *p is
> error_mark_node.
> (cplus_decl_attributes): Don't chain on OpenMP attributes if
> attributes is error_mark_node.
>
> * g++.dg/cpp0x/pr104668.C: New test.
>
> --- gcc/cp/decl2.cc.jj 2022-03-09 09:09:55.415843331 +0100
> +++ gcc/cp/decl2.cc 2022-03-25 17:17:27.769036749 +0100
> @@ -1336,7 +1336,7 @@ splice_template_attributes (tree *attr_p
> tree late_attrs = NULL_TREE;
> tree *q = &late_attrs;
>
> - if (!p)
> + if (!p || *p == error_mark_node)
> return NULL_TREE;
>
> for (; *p; )
> @@ -1644,6 +1644,8 @@ cplus_decl_attributes (tree *decl, tree
> && DECL_CLASS_SCOPE_P (*decl))
> error ("%q+D static data member inside of declare target directive",
> *decl);
> + else if (attributes == error_mark_node)
> + ;
Why not check at the beginning of the function?
> else if (VAR_P (*decl)
> && (processing_template_decl
> || !cp_omp_mappable_type (TREE_TYPE (*decl))))
> --- gcc/testsuite/g++.dg/cpp0x/pr104668.C.jj 2022-03-25 17:25:42.280068058 +0100
> +++ gcc/testsuite/g++.dg/cpp0x/pr104668.C 2022-03-25 17:24:44.862881444 +0100
> @@ -0,0 +1,13 @@
> +// PR c++/104668
> +// { dg-do compile { target c++11 } }
> +// { dg-excess-errors "" }
> +
> +template <class... Ts>
> +void sink(Ts...);
> +template <class... Ts>
> +void f(Ts...) {
> + sink([] { struct alignas:Ts) S {}; }...); }
> +}
> +int main() {
> + f(0);
> +}
>
> Jakub
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] c++: Fix up ICE when cplus_decl_attributes is called with error_mark_node attributes [PR104668]
[not found] ` <Yj4Oe1CHMe1y7wZf@tucnak>
@ 2022-03-25 18:55 ` Jakub Jelinek
2022-04-06 14:43 ` Ping " Jakub Jelinek
0 siblings, 1 reply; 7+ messages in thread
From: Jakub Jelinek @ 2022-03-25 18:55 UTC (permalink / raw)
To: Jason Merrill, gcc-patches
On Fri, Mar 25, 2022 at 07:48:33PM +0100, Jakub Jelinek wrote:
> We then wouldn't propagate TREE_DEPRECATED/TREE_UNAVAILABLE from templates
> to their instantiations and wouldn't diagnose static data members in OpenMP
> declare target.
> But perhaps that is fine, with error_mark_attribute it is error recovery
> anyway.
> Can the splice_template_attributes change stay too, or just
> change cplus_decl_attributes (add it to the early out, remove from other
> spots in the function)?
So like (or without the first hunk):
2022-03-25 Jakub Jelinek <jakub@redhat.com>
PR c++/104668
* decl2.cc (splice_template_attributes): Return NULL if *p is
error_mark_node.
(cplus_decl_attributes): Return early if attributes is
error_mark_node. Don't check that later.
* g++.dg/cpp0x/pr104668.C: New test.
--- gcc/cp/decl2.cc.jj 2022-03-09 09:09:55.415843331 +0100
+++ gcc/cp/decl2.cc 2022-03-25 19:54:12.454749089 +0100
@@ -1336,7 +1336,7 @@ splice_template_attributes (tree *attr_p
tree late_attrs = NULL_TREE;
tree *q = &late_attrs;
- if (!p)
+ if (!p || *p == error_mark_node)
return NULL_TREE;
for (; *p; )
@@ -1631,7 +1631,7 @@ void
cplus_decl_attributes (tree *decl, tree attributes, int flags)
{
if (*decl == NULL_TREE || *decl == void_type_node
- || *decl == error_mark_node)
+ || *decl == error_mark_node || attributes == error_mark_node)
return;
/* Add implicit "omp declare target" attribute if requested. */
@@ -1668,7 +1668,7 @@ cplus_decl_attributes (tree *decl, tree
cp_check_const_attributes (attributes);
- if ((flag_openmp || flag_openmp_simd) && attributes != error_mark_node)
+ if (flag_openmp || flag_openmp_simd)
{
bool diagnosed = false;
for (tree *pa = &attributes; *pa; )
--- gcc/testsuite/g++.dg/cpp0x/pr104668.C.jj 2022-03-25 17:25:42.280068058 +0100
+++ gcc/testsuite/g++.dg/cpp0x/pr104668.C 2022-03-25 17:24:44.862881444 +0100
@@ -0,0 +1,13 @@
+// PR c++/104668
+// { dg-do compile { target c++11 } }
+// { dg-excess-errors "" }
+
+template <class... Ts>
+void sink(Ts...);
+template <class... Ts>
+void f(Ts...) {
+ sink([] { struct alignas:Ts) S {}; }...); }
+}
+int main() {
+ f(0);
+}
Jakub
^ permalink raw reply [flat|nested] 7+ messages in thread
* Ping Re: [PATCH] c++: Fix up ICE when cplus_decl_attributes is called with error_mark_node attributes [PR104668]
2022-03-25 18:55 ` Jakub Jelinek
@ 2022-04-06 14:43 ` Jakub Jelinek
0 siblings, 0 replies; 7+ messages in thread
From: Jakub Jelinek @ 2022-04-06 14:43 UTC (permalink / raw)
To: Jason Merrill; +Cc: gcc-patches
On Fri, Mar 25, 2022 at 07:55:56PM +0100, Jakub Jelinek via Gcc-patches wrote:
> On Fri, Mar 25, 2022 at 07:48:33PM +0100, Jakub Jelinek wrote:
> > We then wouldn't propagate TREE_DEPRECATED/TREE_UNAVAILABLE from templates
> > to their instantiations and wouldn't diagnose static data members in OpenMP
> > declare target.
> > But perhaps that is fine, with error_mark_attribute it is error recovery
> > anyway.
> > Can the splice_template_attributes change stay too, or just
> > change cplus_decl_attributes (add it to the early out, remove from other
> > spots in the function)?
>
> So like (or without the first hunk):
>
> 2022-03-25 Jakub Jelinek <jakub@redhat.com>
>
> PR c++/104668
> * decl2.cc (splice_template_attributes): Return NULL if *p is
> error_mark_node.
> (cplus_decl_attributes): Return early if attributes is
> error_mark_node. Don't check that later.
>
> * g++.dg/cpp0x/pr104668.C: New test.
I'd like to ping this patch. Bootstrapped/regtested successfully on
{powerpc64le,x86_64,i686}-linux.
> --- gcc/cp/decl2.cc.jj 2022-03-09 09:09:55.415843331 +0100
> +++ gcc/cp/decl2.cc 2022-03-25 19:54:12.454749089 +0100
> @@ -1336,7 +1336,7 @@ splice_template_attributes (tree *attr_p
> tree late_attrs = NULL_TREE;
> tree *q = &late_attrs;
>
> - if (!p)
> + if (!p || *p == error_mark_node)
> return NULL_TREE;
>
> for (; *p; )
> @@ -1631,7 +1631,7 @@ void
> cplus_decl_attributes (tree *decl, tree attributes, int flags)
> {
> if (*decl == NULL_TREE || *decl == void_type_node
> - || *decl == error_mark_node)
> + || *decl == error_mark_node || attributes == error_mark_node)
> return;
>
> /* Add implicit "omp declare target" attribute if requested. */
> @@ -1668,7 +1668,7 @@ cplus_decl_attributes (tree *decl, tree
>
> cp_check_const_attributes (attributes);
>
> - if ((flag_openmp || flag_openmp_simd) && attributes != error_mark_node)
> + if (flag_openmp || flag_openmp_simd)
> {
> bool diagnosed = false;
> for (tree *pa = &attributes; *pa; )
> --- gcc/testsuite/g++.dg/cpp0x/pr104668.C.jj 2022-03-25 17:25:42.280068058 +0100
> +++ gcc/testsuite/g++.dg/cpp0x/pr104668.C 2022-03-25 17:24:44.862881444 +0100
> @@ -0,0 +1,13 @@
> +// PR c++/104668
> +// { dg-do compile { target c++11 } }
> +// { dg-excess-errors "" }
> +
> +template <class... Ts>
> +void sink(Ts...);
> +template <class... Ts>
> +void f(Ts...) {
> + sink([] { struct alignas:Ts) S {}; }...); }
> +}
> +int main() {
> + f(0);
> +}
Jakub
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] c++: Fix up ICE when cplus_decl_attributes is called with error_mark_node attributes [PR104668]
2022-03-25 18:08 ` Jason Merrill
[not found] ` <Yj4Oe1CHMe1y7wZf@tucnak>
@ 2022-04-06 15:18 ` Jason Merrill
2022-04-06 15:26 ` Jakub Jelinek
1 sibling, 1 reply; 7+ messages in thread
From: Jason Merrill @ 2022-04-06 15:18 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: gcc-patches
On 3/25/22 14:08, Jason Merrill wrote:
> On 3/25/22 12:34, Jakub Jelinek wrote:
>> Hi!
>>
>> cplus_decl_attributes can be called with attributes equal to
>> error_mark_node, there are some spots in the function that test
>> it or decl_attributes it calls starts with:
>> if (TREE_TYPE (*node) == error_mark_node || attributes ==
>> error_mark_node)
>> return NULL_TREE;
>> But the recent PR104245 change broke this when processing_template_decl
>> is true.
>>
>> This fixes it and also fixes an OpenMP problem with such attributes.
>>
>> Ok for trunk if it passes bootstrap/regtest?
>>
>> 2022-03-25 Jakub Jelinek <jakub@redhat.com>
>>
>> PR c++/104668
>> * decl2.cc (splice_template_attributes): Return NULL if *p is
>> error_mark_node.
>> (cplus_decl_attributes): Don't chain on OpenMP attributes if
>> attributes is error_mark_node.
>>
>> * g++.dg/cpp0x/pr104668.C: New test.
>>
>> --- gcc/cp/decl2.cc.jj 2022-03-09 09:09:55.415843331 +0100
>> +++ gcc/cp/decl2.cc 2022-03-25 17:17:27.769036749 +0100
>> @@ -1336,7 +1336,7 @@ splice_template_attributes (tree *attr_p
>> tree late_attrs = NULL_TREE;
>> tree *q = &late_attrs;
>> - if (!p)
>> + if (!p || *p == error_mark_node)
>> return NULL_TREE;
>> for (; *p; )
>> @@ -1644,6 +1644,8 @@ cplus_decl_attributes (tree *decl, tree
>> && DECL_CLASS_SCOPE_P (*decl))
>> error ("%q+D static data member inside of declare target
>> directive",
>> *decl);
>> + else if (attributes == error_mark_node)
>> + ;
>
> Why not check at the beginning of the function?
You just pinged this patch, but I haven't seen a response to this question.
>> else if (VAR_P (*decl)
>> && (processing_template_decl
>> || !cp_omp_mappable_type (TREE_TYPE (*decl))))
>> --- gcc/testsuite/g++.dg/cpp0x/pr104668.C.jj 2022-03-25
>> 17:25:42.280068058 +0100
>> +++ gcc/testsuite/g++.dg/cpp0x/pr104668.C 2022-03-25
>> 17:24:44.862881444 +0100
>> @@ -0,0 +1,13 @@
>> +// PR c++/104668
>> +// { dg-do compile { target c++11 } }
>> +// { dg-excess-errors "" }
>> +
>> +template <class... Ts>
>> +void sink(Ts...);
>> +template <class... Ts>
>> +void f(Ts...) {
>> + sink([] { struct alignas:Ts) S {}; }...); }
>> +}
>> +int main() {
>> + f(0);
>> +}
>>
>> Jakub
>>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] c++: Fix up ICE when cplus_decl_attributes is called with error_mark_node attributes [PR104668]
2022-04-06 15:18 ` Jason Merrill
@ 2022-04-06 15:26 ` Jakub Jelinek
2022-04-06 15:47 ` Jason Merrill
0 siblings, 1 reply; 7+ messages in thread
From: Jakub Jelinek @ 2022-04-06 15:26 UTC (permalink / raw)
To: Jason Merrill; +Cc: gcc-patches
On Wed, Apr 06, 2022 at 11:18:32AM -0400, Jason Merrill wrote:
> > Why not check at the beginning of the function?
>
> You just pinged this patch, but I haven't seen a response to this question.
I thought the
https://gcc.gnu.org/pipermail/gcc-patches/2022-March/592368.html
is the response to that.
In my =sent I have also a mail which just replied to your
> Why not check at the beginning of the function?
but didn't contain any patch, apparently that wasn't sent due to
some outgoing mail sending issues.
But the above mail is a reply to that mail citing that
reply and including a patch.
Jakub
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] c++: Fix up ICE when cplus_decl_attributes is called with error_mark_node attributes [PR104668]
2022-04-06 15:26 ` Jakub Jelinek
@ 2022-04-06 15:47 ` Jason Merrill
0 siblings, 0 replies; 7+ messages in thread
From: Jason Merrill @ 2022-04-06 15:47 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: gcc-patches
On 4/6/22 11:26, Jakub Jelinek wrote:
> On Wed, Apr 06, 2022 at 11:18:32AM -0400, Jason Merrill wrote:
>>> Why not check at the beginning of the function?
>>
>> You just pinged this patch, but I haven't seen a response to this question.
>
> I thought the
> https://gcc.gnu.org/pipermail/gcc-patches/2022-March/592368.html
> is the response to that.
Weird, AFAICT I never got that message. But yes, that patch is OK.
> In my =sent I have also a mail which just replied to your
>> Why not check at the beginning of the function?
> but didn't contain any patch, apparently that wasn't sent due to
> some outgoing mail sending issues.
> But the above mail is a reply to that mail citing that
> reply and including a patch.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-04-06 15:47 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-25 16:34 [PATCH] c++: Fix up ICE when cplus_decl_attributes is called with error_mark_node attributes [PR104668] Jakub Jelinek
2022-03-25 18:08 ` Jason Merrill
[not found] ` <Yj4Oe1CHMe1y7wZf@tucnak>
2022-03-25 18:55 ` Jakub Jelinek
2022-04-06 14:43 ` Ping " Jakub Jelinek
2022-04-06 15:18 ` Jason Merrill
2022-04-06 15:26 ` Jakub Jelinek
2022-04-06 15:47 ` 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).