* [PATCH] c++: [[deprecated]] on template redecl [PR84542]
@ 2023-12-18 19:50 Patrick Palka
2023-12-18 19:56 ` Marek Polacek
0 siblings, 1 reply; 3+ messages in thread
From: Patrick Palka @ 2023-12-18 19:50 UTC (permalink / raw)
To: gcc-patches; +Cc: jason, Patrick Palka
Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look
OK for trunk?
-- >8 --
The deprecated and unavailable attributes weren't working when used on
a template redeclaration ultimately because the corresponding tree flags
on the underlying decls weren't being merged across redeclarations.
PR c++/84542
gcc/cp/ChangeLog:
* decl.cc (merge_attribute_bits):
gcc/testsuite/ChangeLog:
* g++.dg/ext/attr-deprecated-2.C: No longer XFAIL.
* g++.dg/ext/attr-unavailable-12.C: New test.
---
gcc/cp/decl.cc | 5 ++++-
gcc/testsuite/g++.dg/ext/attr-deprecated-2.C | 4 ++--
gcc/testsuite/g++.dg/ext/attr-unavailable-12.C | 12 ++++++++++++
3 files changed, 18 insertions(+), 3 deletions(-)
create mode 100644 gcc/testsuite/g++.dg/ext/attr-unavailable-12.C
diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc
index 1ffe4c82748..36375ea3c14 100644
--- a/gcc/cp/decl.cc
+++ b/gcc/cp/decl.cc
@@ -1530,6 +1530,10 @@ merge_attribute_bits (tree newdecl, tree olddecl)
DECL_PURE_P (olddecl) |= DECL_PURE_P (newdecl);
DECL_UNINLINABLE (newdecl) |= DECL_UNINLINABLE (olddecl);
DECL_UNINLINABLE (olddecl) |= DECL_UNINLINABLE (newdecl);
+ TREE_DEPRECATED (newdecl) |= TREE_DEPRECATED (olddecl);
+ TREE_DEPRECATED (olddecl) |= TREE_DEPRECATED (newdecl);
+ TREE_UNAVAILABLE (newdecl) |= TREE_UNAVAILABLE (olddecl);
+ TREE_UNAVAILABLE (olddecl) |= TREE_UNAVAILABLE (newdecl);
}
#define GNU_INLINE_P(fn) (DECL_DECLARED_INLINE_P (fn) \
@@ -1542,7 +1546,6 @@ merge_attribute_bits (tree newdecl, tree olddecl)
static bool
duplicate_function_template_decls (tree newdecl, tree olddecl)
{
-
tree newres = DECL_TEMPLATE_RESULT (newdecl);
tree oldres = DECL_TEMPLATE_RESULT (olddecl);
/* Function template declarations can be differentiated by parameter
diff --git a/gcc/testsuite/g++.dg/ext/attr-deprecated-2.C b/gcc/testsuite/g++.dg/ext/attr-deprecated-2.C
index bf9041506d1..6f6c210ddb5 100644
--- a/gcc/testsuite/g++.dg/ext/attr-deprecated-2.C
+++ b/gcc/testsuite/g++.dg/ext/attr-deprecated-2.C
@@ -23,8 +23,8 @@ fdeprecated_primary ();
void use_primary ()
{
// Verify that uses of the now deprecacted primary are diagnosed.
- fdeprecated_primary<void>(); // { dg-warning "deprecated" "bug 84542" { xfail *-*-* } }
- fdeprecated_primary<int>(); // { dg-warning "deprecated" "bug 84542" { xfail *-*-* } }
+ fdeprecated_primary<void>(); // { dg-warning "deprecated" "bug 84542" }
+ fdeprecated_primary<int>(); // { dg-warning "deprecated" "bug 84542" }
}
void use_special ()
diff --git a/gcc/testsuite/g++.dg/ext/attr-unavailable-12.C b/gcc/testsuite/g++.dg/ext/attr-unavailable-12.C
new file mode 100644
index 00000000000..7174abc8bb9
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/attr-unavailable-12.C
@@ -0,0 +1,12 @@
+// PR c++/84542
+
+template<class T>
+void f(T);
+
+template<class T>
+__attribute__((unavailable))
+void f(T) { }
+
+int main() {
+ f(0); // { dg-error "unavailable" }
+}
--
2.43.0.76.g1a87c842ec
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] c++: [[deprecated]] on template redecl [PR84542]
2023-12-18 19:50 [PATCH] c++: [[deprecated]] on template redecl [PR84542] Patrick Palka
@ 2023-12-18 19:56 ` Marek Polacek
2023-12-18 21:35 ` Jason Merrill
0 siblings, 1 reply; 3+ messages in thread
From: Marek Polacek @ 2023-12-18 19:56 UTC (permalink / raw)
To: Patrick Palka; +Cc: gcc-patches, jason
On Mon, Dec 18, 2023 at 02:50:04PM -0500, Patrick Palka wrote:
> Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look
> OK for trunk?
LGTM but...
> -- >8 --
>
> The deprecated and unavailable attributes weren't working when used on
> a template redeclaration ultimately because the corresponding tree flags
> on the underlying decls weren't being merged across redeclarations.
>
> PR c++/84542
>
> gcc/cp/ChangeLog:
>
> * decl.cc (merge_attribute_bits):
...this entry is missing. Thanks,
> gcc/testsuite/ChangeLog:
>
> * g++.dg/ext/attr-deprecated-2.C: No longer XFAIL.
> * g++.dg/ext/attr-unavailable-12.C: New test.
> ---
> gcc/cp/decl.cc | 5 ++++-
> gcc/testsuite/g++.dg/ext/attr-deprecated-2.C | 4 ++--
> gcc/testsuite/g++.dg/ext/attr-unavailable-12.C | 12 ++++++++++++
> 3 files changed, 18 insertions(+), 3 deletions(-)
> create mode 100644 gcc/testsuite/g++.dg/ext/attr-unavailable-12.C
>
> diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc
> index 1ffe4c82748..36375ea3c14 100644
> --- a/gcc/cp/decl.cc
> +++ b/gcc/cp/decl.cc
> @@ -1530,6 +1530,10 @@ merge_attribute_bits (tree newdecl, tree olddecl)
> DECL_PURE_P (olddecl) |= DECL_PURE_P (newdecl);
> DECL_UNINLINABLE (newdecl) |= DECL_UNINLINABLE (olddecl);
> DECL_UNINLINABLE (olddecl) |= DECL_UNINLINABLE (newdecl);
> + TREE_DEPRECATED (newdecl) |= TREE_DEPRECATED (olddecl);
> + TREE_DEPRECATED (olddecl) |= TREE_DEPRECATED (newdecl);
> + TREE_UNAVAILABLE (newdecl) |= TREE_UNAVAILABLE (olddecl);
> + TREE_UNAVAILABLE (olddecl) |= TREE_UNAVAILABLE (newdecl);
> }
>
> #define GNU_INLINE_P(fn) (DECL_DECLARED_INLINE_P (fn) \
> @@ -1542,7 +1546,6 @@ merge_attribute_bits (tree newdecl, tree olddecl)
> static bool
> duplicate_function_template_decls (tree newdecl, tree olddecl)
> {
> -
> tree newres = DECL_TEMPLATE_RESULT (newdecl);
> tree oldres = DECL_TEMPLATE_RESULT (olddecl);
> /* Function template declarations can be differentiated by parameter
> diff --git a/gcc/testsuite/g++.dg/ext/attr-deprecated-2.C b/gcc/testsuite/g++.dg/ext/attr-deprecated-2.C
> index bf9041506d1..6f6c210ddb5 100644
> --- a/gcc/testsuite/g++.dg/ext/attr-deprecated-2.C
> +++ b/gcc/testsuite/g++.dg/ext/attr-deprecated-2.C
> @@ -23,8 +23,8 @@ fdeprecated_primary ();
> void use_primary ()
> {
> // Verify that uses of the now deprecacted primary are diagnosed.
> - fdeprecated_primary<void>(); // { dg-warning "deprecated" "bug 84542" { xfail *-*-* } }
> - fdeprecated_primary<int>(); // { dg-warning "deprecated" "bug 84542" { xfail *-*-* } }
> + fdeprecated_primary<void>(); // { dg-warning "deprecated" "bug 84542" }
> + fdeprecated_primary<int>(); // { dg-warning "deprecated" "bug 84542" }
> }
>
> void use_special ()
> diff --git a/gcc/testsuite/g++.dg/ext/attr-unavailable-12.C b/gcc/testsuite/g++.dg/ext/attr-unavailable-12.C
> new file mode 100644
> index 00000000000..7174abc8bb9
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/ext/attr-unavailable-12.C
> @@ -0,0 +1,12 @@
> +// PR c++/84542
> +
> +template<class T>
> +void f(T);
> +
> +template<class T>
> +__attribute__((unavailable))
> +void f(T) { }
> +
> +int main() {
> + f(0); // { dg-error "unavailable" }
> +}
> --
> 2.43.0.76.g1a87c842ec
>
Marek
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] c++: [[deprecated]] on template redecl [PR84542]
2023-12-18 19:56 ` Marek Polacek
@ 2023-12-18 21:35 ` Jason Merrill
0 siblings, 0 replies; 3+ messages in thread
From: Jason Merrill @ 2023-12-18 21:35 UTC (permalink / raw)
To: Marek Polacek, Patrick Palka; +Cc: gcc-patches
On 12/18/23 14:56, Marek Polacek wrote:
> On Mon, Dec 18, 2023 at 02:50:04PM -0500, Patrick Palka wrote:
>> Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look
>> OK for trunk?
>
> LGTM but...
>
>> -- >8 --
>>
>> The deprecated and unavailable attributes weren't working when used on
>> a template redeclaration ultimately because the corresponding tree flags
>> on the underlying decls weren't being merged across redeclarations.
>>
>> PR c++/84542
>>
>> gcc/cp/ChangeLog:
>>
>> * decl.cc (merge_attribute_bits):
>
> ...this entry is missing. Thanks,
Indeed. OK with that fixed.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-12-18 21:35 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-18 19:50 [PATCH] c++: [[deprecated]] on template redecl [PR84542] Patrick Palka
2023-12-18 19:56 ` Marek Polacek
2023-12-18 21:35 ` 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).