* [PATCH] Fix testcases using __attribute__((noclone)) with Clang
@ 2020-09-16 16:06 Gary Benson
2020-09-30 10:02 ` [PING][PATCH] " Gary Benson
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Gary Benson @ 2020-09-16 16:06 UTC (permalink / raw)
To: gdb-patches
Hi all,
Clang fails to compile a number of files with the following warning:
unknown attribute 'noclone' ignored [-Wunknown-attributes]. This
commit adds a new header, lib/noclone.h, which defines the macro
ATTRIBUTE_NOCLONE accordingly, and updates the relevant testcases
to use it.
Checked on Fedora 32 x86_64, GCC and clang. Is this ok to commit?
Cheers,
Gary
--
gdb/testsuite/ChangeLog:
* lib/noclone.h: New header.
* gdb.base/backtrace.c: Include the above. Replace
__attribute__(noclone)) with ATTRIBUTE_NOCLONE.
* gdb.base/infcall-nested-structs.c: Likewise.
* gdb.base/vla-optimized-out.c: Likewise.
---
gdb/testsuite/ChangeLog | 8 +++
gdb/testsuite/lib/noclone.h | 37 ++++++++++++++
gdb/testsuite/gdb.base/backtrace.c | 8 +--
gdb/testsuite/gdb.base/infcall-nested-structs.c | 65 +++++++++++++------------
gdb/testsuite/gdb.base/vla-optimized-out.c | 4 +-
5 files changed, 86 insertions(+), 36 deletions(-)
create mode 100644 gdb/testsuite/lib/noclone.h
diff --git a/gdb/testsuite/lib/noclone.h b/gdb/testsuite/lib/noclone.h
new file mode 100644
index 0000000..b6a4aa7
--- /dev/null
+++ b/gdb/testsuite/lib/noclone.h
@@ -0,0 +1,37 @@
+/* This file is part of GDB, the GNU debugger.
+
+ Copyright (C) 2020 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* Compatibility macro for __attribute__((noclone)). */
+
+#ifndef NOCLONE_H
+#define NOCLONE_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if __has_attribute(noclone)
+# define ATTRIBUTE_NOCLONE __attribute__((noclone))
+#else
+# define ATTRIBUTE_NOCLONE
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* NOCLONE_H */
diff --git a/gdb/testsuite/gdb.base/backtrace.c b/gdb/testsuite/gdb.base/backtrace.c
index bae8b1a..310a481 100644
--- a/gdb/testsuite/gdb.base/backtrace.c
+++ b/gdb/testsuite/gdb.base/backtrace.c
@@ -15,19 +15,21 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-int __attribute__((noinline,noclone))
+#include "../lib/noclone.h"
+
+int __attribute__((noinline)) ATTRIBUTE_NOCLONE
baz ()
{
return 0; /* Break here. */
}
-int __attribute__((noinline,noclone))
+int __attribute__((noinline)) ATTRIBUTE_NOCLONE
bar ()
{
return baz ();
}
-int __attribute__((noinline,noclone))
+int __attribute__((noinline)) ATTRIBUTE_NOCLONE
foo ()
{
return bar ();
diff --git a/gdb/testsuite/gdb.base/infcall-nested-structs.c b/gdb/testsuite/gdb.base/infcall-nested-structs.c
index c0c8e19..73f417d 100644
--- a/gdb/testsuite/gdb.base/infcall-nested-structs.c
+++ b/gdb/testsuite/gdb.base/infcall-nested-structs.c
@@ -33,6 +33,7 @@
in the structs.exp test script. */
#include <string.h>
+#include "../lib/noclone.h"
/* Useful abreviations. */
typedef char tc;
@@ -51,13 +52,13 @@
#endif /* TEST_COMPLEX */
#define MAKE_CHECK_FUNCS(TYPE) \
- int __attribute__((noinline,noclone)) \
+ int __attribute__((noinline)) ATTRIBUTE_NOCLONE \
check_arg_ ## TYPE (struct TYPE arg) \
{ \
return cmp_ ## TYPE (arg, ref_val_ ## TYPE); \
} \
\
- struct TYPE __attribute__((noinline,noclone)) \
+ struct TYPE __attribute__((noinline)) ATTRIBUTE_NOCLONE \
rtn_str_ ## TYPE (void) \
{ \
return (ref_val_ ## TYPE); \
@@ -128,141 +129,141 @@
#endif
-int __attribute__((noinline,noclone))
+int __attribute__((noinline)) ATTRIBUTE_NOCLONE
cmp_struct_01_01 (struct struct_01_01 a, struct struct_01_01 b)
{ return a.s2.s1.a == b.s2.s1.a; }
-int __attribute__((noinline,noclone))
+int __attribute__((noinline)) ATTRIBUTE_NOCLONE
cmp_struct_01_02 (struct struct_01_02 a, struct struct_01_02 b)
{ return a.a == b.a; }
-int __attribute__((noinline,noclone))
+int __attribute__((noinline)) ATTRIBUTE_NOCLONE
cmp_struct_01_03 (struct struct_01_03 a, struct struct_01_03 b)
{ return a.s4.s3.a == b.s4.s3.a; }
-int __attribute__((noinline,noclone))
+int __attribute__((noinline)) ATTRIBUTE_NOCLONE
cmp_struct_01_04 (struct struct_01_04 a, struct struct_01_04 b)
{ return a.a == b.a; }
-int __attribute__((noinline,noclone))
+int __attribute__((noinline)) ATTRIBUTE_NOCLONE
cmp_struct_02_01 (struct struct_02_01 a, struct struct_02_01 b)
{ return a.s2.s1.a == b.s2.s1.a && a.s2.s1.b == b.s2.s1.b; }
-int __attribute__((noinline,noclone))
+int __attribute__((noinline)) ATTRIBUTE_NOCLONE
cmp_struct_02_02 (struct struct_02_02 a, struct struct_02_02 b)
{ return a.a == b.a && a.b == b.b; }
-int __attribute__((noinline,noclone))
+int __attribute__((noinline)) ATTRIBUTE_NOCLONE
cmp_struct_02_03 (struct struct_02_03 a, struct struct_02_03 b)
{ return a.s4.s3.a == b.s4.s3.a && a.s6.s5.b == b.s6.s5.b; }
-int __attribute__((noinline,noclone))
+int __attribute__((noinline)) ATTRIBUTE_NOCLONE
cmp_struct_02_04 (struct struct_02_04 a, struct struct_02_04 b)
{ return a.a == b.a && a.b == b.b; }
-int __attribute__((noinline,noclone))
+int __attribute__((noinline)) ATTRIBUTE_NOCLONE
cmp_struct_04_01 (struct struct_04_01 a, struct struct_04_01 b)
{ return a.s2.s1.a == b.s2.s1.a && a.s2.s1.b == b.s2.s1.b
&& a.s2.s1.c == b.s2.s1.c && a.s2.s1.d == b.s2.s1.d; }
-int __attribute__((noinline,noclone))
+int __attribute__((noinline)) ATTRIBUTE_NOCLONE
cmp_struct_04_02 (struct struct_04_02 a, struct struct_04_02 b)
{ return a.a == b.a && a.b == b.b && a.c == b.c && a.d == b.d; }
-int __attribute__((noinline,noclone))
+int __attribute__((noinline)) ATTRIBUTE_NOCLONE
cmp_struct_04_03 (struct struct_04_03 a, struct struct_04_03 b)
{ return a.s4.s3.a == b.s4.s3.a && a.s6.s5.b == b.s6.s5.b
&& a.s8.s7.c == b.s8.s7.c && a.s10.s9.d == b.s10.s9.d; }
-int __attribute__((noinline,noclone))
+int __attribute__((noinline)) ATTRIBUTE_NOCLONE
cmp_struct_04_04 (struct struct_04_04 a, struct struct_04_04 b)
{ return a.a == b.a && a.b == b.b && a.c == b.c && a.d == b.d; }
-int __attribute__((noinline,noclone))
+int __attribute__((noinline)) ATTRIBUTE_NOCLONE
cmp_struct_05_01 (struct struct_05_01 a, struct struct_05_01 b)
{ return a.s2.s1.a == b.s2.s1.a && a.s2.s1.b == b.s2.s1.b
&& a.s2.s1.c == b.s2.s1.c && a.s2.s1.d == b.s2.s1.d
&& a.s2.s1.e == b.s2.s1.e; }
-int __attribute__((noinline,noclone))
+int __attribute__((noinline)) ATTRIBUTE_NOCLONE
cmp_struct_05_02 (struct struct_05_02 a, struct struct_05_02 b)
{ return a.a == b.a && a.b == b.b && a.c == b.c && a.d == b.d && a.e == b.e; }
-int __attribute__((noinline,noclone))
+int __attribute__((noinline)) ATTRIBUTE_NOCLONE
cmp_struct_05_03 (struct struct_05_03 a, struct struct_05_03 b)
{ return a.s4.s3.a == b.s4.s3.a && a.s6.s5.b == b.s6.s5.b
&& a.s8.s7.c == b.s8.s7.c && a.s10.s9.d == b.s10.s9.d
&& a.s12.s11.e == b.s12.s11.e; }
-int __attribute__((noinline,noclone))
+int __attribute__((noinline)) ATTRIBUTE_NOCLONE
cmp_struct_05_04 (struct struct_05_04 a, struct struct_05_04 b)
{ return a.a == b.a && a.b == b.b && a.c == b.c && a.d == b.d && a.e == b.e; }
#ifdef __cplusplus
-int __attribute__((noinline,noclone))
+int __attribute__((noinline)) ATTRIBUTE_NOCLONE
cmp_struct_static_02_01 (struct struct_static_02_01 a,
struct struct_static_02_01 b)
{ return a.s2.s1.a == b.s2.s1.a && a.s2.s1.b == b.s2.s1.b; }
-int __attribute__((noinline,noclone))
+int __attribute__((noinline)) ATTRIBUTE_NOCLONE
cmp_struct_static_02_02 (struct struct_static_02_02 a,
struct struct_static_02_02 b)
{ return a.a == b.a && a.b == b.b; }
-int __attribute__((noinline,noclone))
+int __attribute__((noinline)) ATTRIBUTE_NOCLONE
cmp_struct_static_02_03 (struct struct_static_02_03 a,
struct struct_static_02_03 b)
{ return a.s4.s3.a == b.s4.s3.a && a.s6.s5.b == b.s6.s5.b; }
-int __attribute__((noinline,noclone))
+int __attribute__((noinline)) ATTRIBUTE_NOCLONE
cmp_struct_static_02_04 (struct struct_static_02_04 a,
struct struct_static_02_04 b)
{ return a.a == b.a && a.b == b.b; }
-int __attribute__((noinline,noclone))
+int __attribute__((noinline)) ATTRIBUTE_NOCLONE
cmp_struct_static_04_01 (struct struct_static_04_01 a,
struct struct_static_04_01 b)
{ return a.s2.s1.a == b.s2.s1.a && a.s2.s1.b == b.s2.s1.b
&& a.s2.s1.c == b.s2.s1.c && a.s2.s1.d == b.s2.s1.d; }
-int __attribute__((noinline,noclone))
+int __attribute__((noinline)) ATTRIBUTE_NOCLONE
cmp_struct_static_04_02 (struct struct_static_04_02 a,
struct struct_static_04_02 b)
{ return a.a == b.a && a.b == b.b && a.c == b.c && a.d == b.d; }
-int __attribute__((noinline,noclone))
+int __attribute__((noinline)) ATTRIBUTE_NOCLONE
cmp_struct_static_04_03 (struct struct_static_04_03 a,
struct struct_static_04_03 b)
{ return a.s4.s3.a == b.s4.s3.a && a.s6.s5.b == b.s6.s5.b
&& a.s8.s7.c == b.s8.s7.c && a.s10.s9.d == b.s10.s9.d; }
-int __attribute__((noinline,noclone))
+int __attribute__((noinline)) ATTRIBUTE_NOCLONE
cmp_struct_static_04_04 (struct struct_static_04_04 a,
struct struct_static_04_04 b)
{ return a.a == b.a && a.b == b.b && a.c == b.c && a.d == b.d; }
-int __attribute__((noinline,noclone))
+int __attribute__((noinline)) ATTRIBUTE_NOCLONE
cmp_struct_static_06_01 (struct struct_static_06_01 a,
struct struct_static_06_01 b)
{ return a.s2.s1.a == b.s2.s1.a && a.s2.s1.b == b.s2.s1.b
&& a.s2.s1.c == b.s2.s1.c && a.s2.s1.d == b.s2.s1.d
&& a.s2.s1.e == b.s2.s1.e && a.f == b.f; }
-int __attribute__((noinline,noclone))
+int __attribute__((noinline)) ATTRIBUTE_NOCLONE
cmp_struct_static_06_02 (struct struct_static_06_02 a,
struct struct_static_06_02 b)
{ return a.a == b.a && a.b == b.b && a.c == b.c && a.d == b.d && a.e == b.e
&& a.f == b.f; }
-int __attribute__((noinline,noclone))
+int __attribute__((noinline)) ATTRIBUTE_NOCLONE
cmp_struct_static_06_03 (struct struct_static_06_03 a,
struct struct_static_06_03 b)
{ return a.s4.s3.a == b.s4.s3.a && a.s6.s5.b == b.s6.s5.b
&& a.s8.s7.c == b.s8.s7.c && a.s10.s9.d == b.s10.s9.d
&& a.s12.s11.e == b.s12.s11.e && a.s12.s11.f == b.s12.s11.f; }
-int __attribute__((noinline,noclone))
+int __attribute__((noinline)) ATTRIBUTE_NOCLONE
cmp_struct_static_06_04 (struct struct_static_06_04 a,
struct struct_static_06_04 b)
{ return a.a == b.a && a.b == b.b && a.c == b.c && a.d == b.d && a.e == b.e
@@ -366,7 +367,7 @@ int __attribute__((noinline,noclone))
#define CALL_LINE(NAME) val += check_arg_ ## NAME (rtn_str_ ## NAME ())
-int __attribute__((noinline,noclone))
+int __attribute__((noinline)) ATTRIBUTE_NOCLONE
call_all ()
{
int val = 0;
@@ -407,7 +408,7 @@ int __attribute__((noinline,noclone))
int volatile v = 1;
-void __attribute__((noinline, noclone))
+void __attribute__((noinline)) ATTRIBUTE_NOCLONE
breakpt (void)
{
v++;
diff --git a/gdb/testsuite/gdb.base/vla-optimized-out.c b/gdb/testsuite/gdb.base/vla-optimized-out.c
index edc2b5e..4520f98 100644
--- a/gdb/testsuite/gdb.base/vla-optimized-out.c
+++ b/gdb/testsuite/gdb.base/vla-optimized-out.c
@@ -18,9 +18,11 @@
/* The version of this test-case with f1 tagged with noinline only is equivalent
to gcc/testsuite/gcc.dg/guality/vla-1.c. */
+#include "../lib/noclone.h"
+
int
#ifdef NOCLONE
-__attribute__((noinline, noclone))
+__attribute__((noinline)) ATTRIBUTE_NOCLONE
#else
__attribute__((noinline))
#endif
--
1.8.3.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PING][PATCH] Fix testcases using __attribute__((noclone)) with Clang
2020-09-16 16:06 [PATCH] Fix testcases using __attribute__((noclone)) with Clang Gary Benson
@ 2020-09-30 10:02 ` Gary Benson
2020-10-14 9:27 ` [PING^2][PATCH] " Gary Benson
2020-10-23 13:29 ` [PATCH] " Pedro Alves
2 siblings, 0 replies; 6+ messages in thread
From: Gary Benson @ 2020-09-30 10:02 UTC (permalink / raw)
To: gdb-patches
Gary Benson wrote:
> Hi all,
>
> Clang fails to compile a number of files with the following warning:
> unknown attribute 'noclone' ignored [-Wunknown-attributes]. This
> commit adds a new header, lib/noclone.h, which defines the macro
> ATTRIBUTE_NOCLONE accordingly, and updates the relevant testcases
> to use it.
>
> Checked on Fedora 32 x86_64, GCC and clang. Is this ok to commit?
>
> Cheers,
> Gary
>
> --
> gdb/testsuite/ChangeLog:
>
> * lib/noclone.h: New header.
> * gdb.base/backtrace.c: Include the above. Replace
> __attribute__(noclone)) with ATTRIBUTE_NOCLONE.
> * gdb.base/infcall-nested-structs.c: Likewise.
> * gdb.base/vla-optimized-out.c: Likewise.
> ---
> gdb/testsuite/ChangeLog | 8 +++
> gdb/testsuite/lib/noclone.h | 37 ++++++++++++++
> gdb/testsuite/gdb.base/backtrace.c | 8 +--
> gdb/testsuite/gdb.base/infcall-nested-structs.c | 65 +++++++++++++------------
> gdb/testsuite/gdb.base/vla-optimized-out.c | 4 +-
> 5 files changed, 86 insertions(+), 36 deletions(-)
> create mode 100644 gdb/testsuite/lib/noclone.h
>
> diff --git a/gdb/testsuite/lib/noclone.h b/gdb/testsuite/lib/noclone.h
> new file mode 100644
> index 0000000..b6a4aa7
> --- /dev/null
> +++ b/gdb/testsuite/lib/noclone.h
> @@ -0,0 +1,37 @@
> +/* This file is part of GDB, the GNU debugger.
> +
> + Copyright (C) 2020 Free Software Foundation, Inc.
> +
> + This program is free software; you can redistribute it and/or modify
> + it under the terms of the GNU General Public License as published by
> + the Free Software Foundation; either version 3 of the License, or
> + (at your option) any later version.
> +
> + This program is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + GNU General Public License for more details.
> +
> + You should have received a copy of the GNU General Public License
> + along with this program. If not, see <http://www.gnu.org/licenses/>. */
> +
> +/* Compatibility macro for __attribute__((noclone)). */
> +
> +#ifndef NOCLONE_H
> +#define NOCLONE_H
> +
> +#ifdef __cplusplus
> +extern "C" {
> +#endif
> +
> +#if __has_attribute(noclone)
> +# define ATTRIBUTE_NOCLONE __attribute__((noclone))
> +#else
> +# define ATTRIBUTE_NOCLONE
> +#endif
> +
> +#ifdef __cplusplus
> +}
> +#endif
> +
> +#endif /* NOCLONE_H */
> diff --git a/gdb/testsuite/gdb.base/backtrace.c b/gdb/testsuite/gdb.base/backtrace.c
> index bae8b1a..310a481 100644
> --- a/gdb/testsuite/gdb.base/backtrace.c
> +++ b/gdb/testsuite/gdb.base/backtrace.c
> @@ -15,19 +15,21 @@
> You should have received a copy of the GNU General Public License
> along with this program. If not, see <http://www.gnu.org/licenses/>. */
>
> -int __attribute__((noinline,noclone))
> +#include "../lib/noclone.h"
> +
> +int __attribute__((noinline)) ATTRIBUTE_NOCLONE
> baz ()
> {
> return 0; /* Break here. */
> }
>
> -int __attribute__((noinline,noclone))
> +int __attribute__((noinline)) ATTRIBUTE_NOCLONE
> bar ()
> {
> return baz ();
> }
>
> -int __attribute__((noinline,noclone))
> +int __attribute__((noinline)) ATTRIBUTE_NOCLONE
> foo ()
> {
> return bar ();
> diff --git a/gdb/testsuite/gdb.base/infcall-nested-structs.c b/gdb/testsuite/gdb.base/infcall-nested-structs.c
> index c0c8e19..73f417d 100644
> --- a/gdb/testsuite/gdb.base/infcall-nested-structs.c
> +++ b/gdb/testsuite/gdb.base/infcall-nested-structs.c
> @@ -33,6 +33,7 @@
> in the structs.exp test script. */
>
> #include <string.h>
> +#include "../lib/noclone.h"
>
> /* Useful abreviations. */
> typedef char tc;
> @@ -51,13 +52,13 @@
> #endif /* TEST_COMPLEX */
>
> #define MAKE_CHECK_FUNCS(TYPE) \
> - int __attribute__((noinline,noclone)) \
> + int __attribute__((noinline)) ATTRIBUTE_NOCLONE \
> check_arg_ ## TYPE (struct TYPE arg) \
> { \
> return cmp_ ## TYPE (arg, ref_val_ ## TYPE); \
> } \
> \
> - struct TYPE __attribute__((noinline,noclone)) \
> + struct TYPE __attribute__((noinline)) ATTRIBUTE_NOCLONE \
> rtn_str_ ## TYPE (void) \
> { \
> return (ref_val_ ## TYPE); \
> @@ -128,141 +129,141 @@
>
> #endif
>
> -int __attribute__((noinline,noclone))
> +int __attribute__((noinline)) ATTRIBUTE_NOCLONE
> cmp_struct_01_01 (struct struct_01_01 a, struct struct_01_01 b)
> { return a.s2.s1.a == b.s2.s1.a; }
>
> -int __attribute__((noinline,noclone))
> +int __attribute__((noinline)) ATTRIBUTE_NOCLONE
> cmp_struct_01_02 (struct struct_01_02 a, struct struct_01_02 b)
> { return a.a == b.a; }
>
> -int __attribute__((noinline,noclone))
> +int __attribute__((noinline)) ATTRIBUTE_NOCLONE
> cmp_struct_01_03 (struct struct_01_03 a, struct struct_01_03 b)
> { return a.s4.s3.a == b.s4.s3.a; }
>
> -int __attribute__((noinline,noclone))
> +int __attribute__((noinline)) ATTRIBUTE_NOCLONE
> cmp_struct_01_04 (struct struct_01_04 a, struct struct_01_04 b)
> { return a.a == b.a; }
>
> -int __attribute__((noinline,noclone))
> +int __attribute__((noinline)) ATTRIBUTE_NOCLONE
> cmp_struct_02_01 (struct struct_02_01 a, struct struct_02_01 b)
> { return a.s2.s1.a == b.s2.s1.a && a.s2.s1.b == b.s2.s1.b; }
>
> -int __attribute__((noinline,noclone))
> +int __attribute__((noinline)) ATTRIBUTE_NOCLONE
> cmp_struct_02_02 (struct struct_02_02 a, struct struct_02_02 b)
> { return a.a == b.a && a.b == b.b; }
>
> -int __attribute__((noinline,noclone))
> +int __attribute__((noinline)) ATTRIBUTE_NOCLONE
> cmp_struct_02_03 (struct struct_02_03 a, struct struct_02_03 b)
> { return a.s4.s3.a == b.s4.s3.a && a.s6.s5.b == b.s6.s5.b; }
>
> -int __attribute__((noinline,noclone))
> +int __attribute__((noinline)) ATTRIBUTE_NOCLONE
> cmp_struct_02_04 (struct struct_02_04 a, struct struct_02_04 b)
> { return a.a == b.a && a.b == b.b; }
>
> -int __attribute__((noinline,noclone))
> +int __attribute__((noinline)) ATTRIBUTE_NOCLONE
> cmp_struct_04_01 (struct struct_04_01 a, struct struct_04_01 b)
> { return a.s2.s1.a == b.s2.s1.a && a.s2.s1.b == b.s2.s1.b
> && a.s2.s1.c == b.s2.s1.c && a.s2.s1.d == b.s2.s1.d; }
>
> -int __attribute__((noinline,noclone))
> +int __attribute__((noinline)) ATTRIBUTE_NOCLONE
> cmp_struct_04_02 (struct struct_04_02 a, struct struct_04_02 b)
> { return a.a == b.a && a.b == b.b && a.c == b.c && a.d == b.d; }
>
> -int __attribute__((noinline,noclone))
> +int __attribute__((noinline)) ATTRIBUTE_NOCLONE
> cmp_struct_04_03 (struct struct_04_03 a, struct struct_04_03 b)
> { return a.s4.s3.a == b.s4.s3.a && a.s6.s5.b == b.s6.s5.b
> && a.s8.s7.c == b.s8.s7.c && a.s10.s9.d == b.s10.s9.d; }
>
> -int __attribute__((noinline,noclone))
> +int __attribute__((noinline)) ATTRIBUTE_NOCLONE
> cmp_struct_04_04 (struct struct_04_04 a, struct struct_04_04 b)
> { return a.a == b.a && a.b == b.b && a.c == b.c && a.d == b.d; }
>
> -int __attribute__((noinline,noclone))
> +int __attribute__((noinline)) ATTRIBUTE_NOCLONE
> cmp_struct_05_01 (struct struct_05_01 a, struct struct_05_01 b)
> { return a.s2.s1.a == b.s2.s1.a && a.s2.s1.b == b.s2.s1.b
> && a.s2.s1.c == b.s2.s1.c && a.s2.s1.d == b.s2.s1.d
> && a.s2.s1.e == b.s2.s1.e; }
>
> -int __attribute__((noinline,noclone))
> +int __attribute__((noinline)) ATTRIBUTE_NOCLONE
> cmp_struct_05_02 (struct struct_05_02 a, struct struct_05_02 b)
> { return a.a == b.a && a.b == b.b && a.c == b.c && a.d == b.d && a.e == b.e; }
>
> -int __attribute__((noinline,noclone))
> +int __attribute__((noinline)) ATTRIBUTE_NOCLONE
> cmp_struct_05_03 (struct struct_05_03 a, struct struct_05_03 b)
> { return a.s4.s3.a == b.s4.s3.a && a.s6.s5.b == b.s6.s5.b
> && a.s8.s7.c == b.s8.s7.c && a.s10.s9.d == b.s10.s9.d
> && a.s12.s11.e == b.s12.s11.e; }
>
> -int __attribute__((noinline,noclone))
> +int __attribute__((noinline)) ATTRIBUTE_NOCLONE
> cmp_struct_05_04 (struct struct_05_04 a, struct struct_05_04 b)
> { return a.a == b.a && a.b == b.b && a.c == b.c && a.d == b.d && a.e == b.e; }
>
> #ifdef __cplusplus
>
> -int __attribute__((noinline,noclone))
> +int __attribute__((noinline)) ATTRIBUTE_NOCLONE
> cmp_struct_static_02_01 (struct struct_static_02_01 a,
> struct struct_static_02_01 b)
> { return a.s2.s1.a == b.s2.s1.a && a.s2.s1.b == b.s2.s1.b; }
>
> -int __attribute__((noinline,noclone))
> +int __attribute__((noinline)) ATTRIBUTE_NOCLONE
> cmp_struct_static_02_02 (struct struct_static_02_02 a,
> struct struct_static_02_02 b)
> { return a.a == b.a && a.b == b.b; }
>
> -int __attribute__((noinline,noclone))
> +int __attribute__((noinline)) ATTRIBUTE_NOCLONE
> cmp_struct_static_02_03 (struct struct_static_02_03 a,
> struct struct_static_02_03 b)
> { return a.s4.s3.a == b.s4.s3.a && a.s6.s5.b == b.s6.s5.b; }
>
> -int __attribute__((noinline,noclone))
> +int __attribute__((noinline)) ATTRIBUTE_NOCLONE
> cmp_struct_static_02_04 (struct struct_static_02_04 a,
> struct struct_static_02_04 b)
> { return a.a == b.a && a.b == b.b; }
>
> -int __attribute__((noinline,noclone))
> +int __attribute__((noinline)) ATTRIBUTE_NOCLONE
> cmp_struct_static_04_01 (struct struct_static_04_01 a,
> struct struct_static_04_01 b)
> { return a.s2.s1.a == b.s2.s1.a && a.s2.s1.b == b.s2.s1.b
> && a.s2.s1.c == b.s2.s1.c && a.s2.s1.d == b.s2.s1.d; }
>
> -int __attribute__((noinline,noclone))
> +int __attribute__((noinline)) ATTRIBUTE_NOCLONE
> cmp_struct_static_04_02 (struct struct_static_04_02 a,
> struct struct_static_04_02 b)
> { return a.a == b.a && a.b == b.b && a.c == b.c && a.d == b.d; }
>
> -int __attribute__((noinline,noclone))
> +int __attribute__((noinline)) ATTRIBUTE_NOCLONE
> cmp_struct_static_04_03 (struct struct_static_04_03 a,
> struct struct_static_04_03 b)
> { return a.s4.s3.a == b.s4.s3.a && a.s6.s5.b == b.s6.s5.b
> && a.s8.s7.c == b.s8.s7.c && a.s10.s9.d == b.s10.s9.d; }
>
> -int __attribute__((noinline,noclone))
> +int __attribute__((noinline)) ATTRIBUTE_NOCLONE
> cmp_struct_static_04_04 (struct struct_static_04_04 a,
> struct struct_static_04_04 b)
> { return a.a == b.a && a.b == b.b && a.c == b.c && a.d == b.d; }
>
> -int __attribute__((noinline,noclone))
> +int __attribute__((noinline)) ATTRIBUTE_NOCLONE
> cmp_struct_static_06_01 (struct struct_static_06_01 a,
> struct struct_static_06_01 b)
> { return a.s2.s1.a == b.s2.s1.a && a.s2.s1.b == b.s2.s1.b
> && a.s2.s1.c == b.s2.s1.c && a.s2.s1.d == b.s2.s1.d
> && a.s2.s1.e == b.s2.s1.e && a.f == b.f; }
>
> -int __attribute__((noinline,noclone))
> +int __attribute__((noinline)) ATTRIBUTE_NOCLONE
> cmp_struct_static_06_02 (struct struct_static_06_02 a,
> struct struct_static_06_02 b)
> { return a.a == b.a && a.b == b.b && a.c == b.c && a.d == b.d && a.e == b.e
> && a.f == b.f; }
>
> -int __attribute__((noinline,noclone))
> +int __attribute__((noinline)) ATTRIBUTE_NOCLONE
> cmp_struct_static_06_03 (struct struct_static_06_03 a,
> struct struct_static_06_03 b)
> { return a.s4.s3.a == b.s4.s3.a && a.s6.s5.b == b.s6.s5.b
> && a.s8.s7.c == b.s8.s7.c && a.s10.s9.d == b.s10.s9.d
> && a.s12.s11.e == b.s12.s11.e && a.s12.s11.f == b.s12.s11.f; }
>
> -int __attribute__((noinline,noclone))
> +int __attribute__((noinline)) ATTRIBUTE_NOCLONE
> cmp_struct_static_06_04 (struct struct_static_06_04 a,
> struct struct_static_06_04 b)
> { return a.a == b.a && a.b == b.b && a.c == b.c && a.d == b.d && a.e == b.e
> @@ -366,7 +367,7 @@ int __attribute__((noinline,noclone))
>
> #define CALL_LINE(NAME) val += check_arg_ ## NAME (rtn_str_ ## NAME ())
>
> -int __attribute__((noinline,noclone))
> +int __attribute__((noinline)) ATTRIBUTE_NOCLONE
> call_all ()
> {
> int val = 0;
> @@ -407,7 +408,7 @@ int __attribute__((noinline,noclone))
>
> int volatile v = 1;
>
> -void __attribute__((noinline, noclone))
> +void __attribute__((noinline)) ATTRIBUTE_NOCLONE
> breakpt (void)
> {
> v++;
> diff --git a/gdb/testsuite/gdb.base/vla-optimized-out.c b/gdb/testsuite/gdb.base/vla-optimized-out.c
> index edc2b5e..4520f98 100644
> --- a/gdb/testsuite/gdb.base/vla-optimized-out.c
> +++ b/gdb/testsuite/gdb.base/vla-optimized-out.c
> @@ -18,9 +18,11 @@
> /* The version of this test-case with f1 tagged with noinline only is equivalent
> to gcc/testsuite/gcc.dg/guality/vla-1.c. */
>
> +#include "../lib/noclone.h"
> +
> int
> #ifdef NOCLONE
> -__attribute__((noinline, noclone))
> +__attribute__((noinline)) ATTRIBUTE_NOCLONE
> #else
> __attribute__((noinline))
> #endif
> --
> 1.8.3.1
>
--
Gary Benson - he / him / his
Principal Software Engineer, Red Hat
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PING^2][PATCH] Fix testcases using __attribute__((noclone)) with Clang
2020-09-16 16:06 [PATCH] Fix testcases using __attribute__((noclone)) with Clang Gary Benson
2020-09-30 10:02 ` [PING][PATCH] " Gary Benson
@ 2020-10-14 9:27 ` Gary Benson
2020-10-23 13:29 ` [PATCH] " Pedro Alves
2 siblings, 0 replies; 6+ messages in thread
From: Gary Benson @ 2020-10-14 9:27 UTC (permalink / raw)
To: gdb-patches
Gary Benson wrote:
> Hi all,
>
> Clang fails to compile a number of files with the following warning:
> unknown attribute 'noclone' ignored [-Wunknown-attributes]. This
> commit adds a new header, lib/noclone.h, which defines the macro
> ATTRIBUTE_NOCLONE accordingly, and updates the relevant testcases
> to use it.
>
> Checked on Fedora 32 x86_64, GCC and clang. Is this ok to commit?
>
> Cheers,
> Gary
>
> --
> gdb/testsuite/ChangeLog:
>
> * lib/noclone.h: New header.
> * gdb.base/backtrace.c: Include the above. Replace
> __attribute__(noclone)) with ATTRIBUTE_NOCLONE.
> * gdb.base/infcall-nested-structs.c: Likewise.
> * gdb.base/vla-optimized-out.c: Likewise.
> ---
> gdb/testsuite/ChangeLog | 8 +++
> gdb/testsuite/lib/noclone.h | 37 ++++++++++++++
> gdb/testsuite/gdb.base/backtrace.c | 8 +--
> gdb/testsuite/gdb.base/infcall-nested-structs.c | 65 +++++++++++++------------
> gdb/testsuite/gdb.base/vla-optimized-out.c | 4 +-
> 5 files changed, 86 insertions(+), 36 deletions(-)
> create mode 100644 gdb/testsuite/lib/noclone.h
>
> diff --git a/gdb/testsuite/lib/noclone.h b/gdb/testsuite/lib/noclone.h
> new file mode 100644
> index 0000000..b6a4aa7
> --- /dev/null
> +++ b/gdb/testsuite/lib/noclone.h
> @@ -0,0 +1,37 @@
> +/* This file is part of GDB, the GNU debugger.
> +
> + Copyright (C) 2020 Free Software Foundation, Inc.
> +
> + This program is free software; you can redistribute it and/or modify
> + it under the terms of the GNU General Public License as published by
> + the Free Software Foundation; either version 3 of the License, or
> + (at your option) any later version.
> +
> + This program is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + GNU General Public License for more details.
> +
> + You should have received a copy of the GNU General Public License
> + along with this program. If not, see <http://www.gnu.org/licenses/>. */
> +
> +/* Compatibility macro for __attribute__((noclone)). */
> +
> +#ifndef NOCLONE_H
> +#define NOCLONE_H
> +
> +#ifdef __cplusplus
> +extern "C" {
> +#endif
> +
> +#if __has_attribute(noclone)
> +# define ATTRIBUTE_NOCLONE __attribute__((noclone))
> +#else
> +# define ATTRIBUTE_NOCLONE
> +#endif
> +
> +#ifdef __cplusplus
> +}
> +#endif
> +
> +#endif /* NOCLONE_H */
> diff --git a/gdb/testsuite/gdb.base/backtrace.c b/gdb/testsuite/gdb.base/backtrace.c
> index bae8b1a..310a481 100644
> --- a/gdb/testsuite/gdb.base/backtrace.c
> +++ b/gdb/testsuite/gdb.base/backtrace.c
> @@ -15,19 +15,21 @@
> You should have received a copy of the GNU General Public License
> along with this program. If not, see <http://www.gnu.org/licenses/>. */
>
> -int __attribute__((noinline,noclone))
> +#include "../lib/noclone.h"
> +
> +int __attribute__((noinline)) ATTRIBUTE_NOCLONE
> baz ()
> {
> return 0; /* Break here. */
> }
>
> -int __attribute__((noinline,noclone))
> +int __attribute__((noinline)) ATTRIBUTE_NOCLONE
> bar ()
> {
> return baz ();
> }
>
> -int __attribute__((noinline,noclone))
> +int __attribute__((noinline)) ATTRIBUTE_NOCLONE
> foo ()
> {
> return bar ();
> diff --git a/gdb/testsuite/gdb.base/infcall-nested-structs.c b/gdb/testsuite/gdb.base/infcall-nested-structs.c
> index c0c8e19..73f417d 100644
> --- a/gdb/testsuite/gdb.base/infcall-nested-structs.c
> +++ b/gdb/testsuite/gdb.base/infcall-nested-structs.c
> @@ -33,6 +33,7 @@
> in the structs.exp test script. */
>
> #include <string.h>
> +#include "../lib/noclone.h"
>
> /* Useful abreviations. */
> typedef char tc;
> @@ -51,13 +52,13 @@
> #endif /* TEST_COMPLEX */
>
> #define MAKE_CHECK_FUNCS(TYPE) \
> - int __attribute__((noinline,noclone)) \
> + int __attribute__((noinline)) ATTRIBUTE_NOCLONE \
> check_arg_ ## TYPE (struct TYPE arg) \
> { \
> return cmp_ ## TYPE (arg, ref_val_ ## TYPE); \
> } \
> \
> - struct TYPE __attribute__((noinline,noclone)) \
> + struct TYPE __attribute__((noinline)) ATTRIBUTE_NOCLONE \
> rtn_str_ ## TYPE (void) \
> { \
> return (ref_val_ ## TYPE); \
> @@ -128,141 +129,141 @@
>
> #endif
>
> -int __attribute__((noinline,noclone))
> +int __attribute__((noinline)) ATTRIBUTE_NOCLONE
> cmp_struct_01_01 (struct struct_01_01 a, struct struct_01_01 b)
> { return a.s2.s1.a == b.s2.s1.a; }
>
> -int __attribute__((noinline,noclone))
> +int __attribute__((noinline)) ATTRIBUTE_NOCLONE
> cmp_struct_01_02 (struct struct_01_02 a, struct struct_01_02 b)
> { return a.a == b.a; }
>
> -int __attribute__((noinline,noclone))
> +int __attribute__((noinline)) ATTRIBUTE_NOCLONE
> cmp_struct_01_03 (struct struct_01_03 a, struct struct_01_03 b)
> { return a.s4.s3.a == b.s4.s3.a; }
>
> -int __attribute__((noinline,noclone))
> +int __attribute__((noinline)) ATTRIBUTE_NOCLONE
> cmp_struct_01_04 (struct struct_01_04 a, struct struct_01_04 b)
> { return a.a == b.a; }
>
> -int __attribute__((noinline,noclone))
> +int __attribute__((noinline)) ATTRIBUTE_NOCLONE
> cmp_struct_02_01 (struct struct_02_01 a, struct struct_02_01 b)
> { return a.s2.s1.a == b.s2.s1.a && a.s2.s1.b == b.s2.s1.b; }
>
> -int __attribute__((noinline,noclone))
> +int __attribute__((noinline)) ATTRIBUTE_NOCLONE
> cmp_struct_02_02 (struct struct_02_02 a, struct struct_02_02 b)
> { return a.a == b.a && a.b == b.b; }
>
> -int __attribute__((noinline,noclone))
> +int __attribute__((noinline)) ATTRIBUTE_NOCLONE
> cmp_struct_02_03 (struct struct_02_03 a, struct struct_02_03 b)
> { return a.s4.s3.a == b.s4.s3.a && a.s6.s5.b == b.s6.s5.b; }
>
> -int __attribute__((noinline,noclone))
> +int __attribute__((noinline)) ATTRIBUTE_NOCLONE
> cmp_struct_02_04 (struct struct_02_04 a, struct struct_02_04 b)
> { return a.a == b.a && a.b == b.b; }
>
> -int __attribute__((noinline,noclone))
> +int __attribute__((noinline)) ATTRIBUTE_NOCLONE
> cmp_struct_04_01 (struct struct_04_01 a, struct struct_04_01 b)
> { return a.s2.s1.a == b.s2.s1.a && a.s2.s1.b == b.s2.s1.b
> && a.s2.s1.c == b.s2.s1.c && a.s2.s1.d == b.s2.s1.d; }
>
> -int __attribute__((noinline,noclone))
> +int __attribute__((noinline)) ATTRIBUTE_NOCLONE
> cmp_struct_04_02 (struct struct_04_02 a, struct struct_04_02 b)
> { return a.a == b.a && a.b == b.b && a.c == b.c && a.d == b.d; }
>
> -int __attribute__((noinline,noclone))
> +int __attribute__((noinline)) ATTRIBUTE_NOCLONE
> cmp_struct_04_03 (struct struct_04_03 a, struct struct_04_03 b)
> { return a.s4.s3.a == b.s4.s3.a && a.s6.s5.b == b.s6.s5.b
> && a.s8.s7.c == b.s8.s7.c && a.s10.s9.d == b.s10.s9.d; }
>
> -int __attribute__((noinline,noclone))
> +int __attribute__((noinline)) ATTRIBUTE_NOCLONE
> cmp_struct_04_04 (struct struct_04_04 a, struct struct_04_04 b)
> { return a.a == b.a && a.b == b.b && a.c == b.c && a.d == b.d; }
>
> -int __attribute__((noinline,noclone))
> +int __attribute__((noinline)) ATTRIBUTE_NOCLONE
> cmp_struct_05_01 (struct struct_05_01 a, struct struct_05_01 b)
> { return a.s2.s1.a == b.s2.s1.a && a.s2.s1.b == b.s2.s1.b
> && a.s2.s1.c == b.s2.s1.c && a.s2.s1.d == b.s2.s1.d
> && a.s2.s1.e == b.s2.s1.e; }
>
> -int __attribute__((noinline,noclone))
> +int __attribute__((noinline)) ATTRIBUTE_NOCLONE
> cmp_struct_05_02 (struct struct_05_02 a, struct struct_05_02 b)
> { return a.a == b.a && a.b == b.b && a.c == b.c && a.d == b.d && a.e == b.e; }
>
> -int __attribute__((noinline,noclone))
> +int __attribute__((noinline)) ATTRIBUTE_NOCLONE
> cmp_struct_05_03 (struct struct_05_03 a, struct struct_05_03 b)
> { return a.s4.s3.a == b.s4.s3.a && a.s6.s5.b == b.s6.s5.b
> && a.s8.s7.c == b.s8.s7.c && a.s10.s9.d == b.s10.s9.d
> && a.s12.s11.e == b.s12.s11.e; }
>
> -int __attribute__((noinline,noclone))
> +int __attribute__((noinline)) ATTRIBUTE_NOCLONE
> cmp_struct_05_04 (struct struct_05_04 a, struct struct_05_04 b)
> { return a.a == b.a && a.b == b.b && a.c == b.c && a.d == b.d && a.e == b.e; }
>
> #ifdef __cplusplus
>
> -int __attribute__((noinline,noclone))
> +int __attribute__((noinline)) ATTRIBUTE_NOCLONE
> cmp_struct_static_02_01 (struct struct_static_02_01 a,
> struct struct_static_02_01 b)
> { return a.s2.s1.a == b.s2.s1.a && a.s2.s1.b == b.s2.s1.b; }
>
> -int __attribute__((noinline,noclone))
> +int __attribute__((noinline)) ATTRIBUTE_NOCLONE
> cmp_struct_static_02_02 (struct struct_static_02_02 a,
> struct struct_static_02_02 b)
> { return a.a == b.a && a.b == b.b; }
>
> -int __attribute__((noinline,noclone))
> +int __attribute__((noinline)) ATTRIBUTE_NOCLONE
> cmp_struct_static_02_03 (struct struct_static_02_03 a,
> struct struct_static_02_03 b)
> { return a.s4.s3.a == b.s4.s3.a && a.s6.s5.b == b.s6.s5.b; }
>
> -int __attribute__((noinline,noclone))
> +int __attribute__((noinline)) ATTRIBUTE_NOCLONE
> cmp_struct_static_02_04 (struct struct_static_02_04 a,
> struct struct_static_02_04 b)
> { return a.a == b.a && a.b == b.b; }
>
> -int __attribute__((noinline,noclone))
> +int __attribute__((noinline)) ATTRIBUTE_NOCLONE
> cmp_struct_static_04_01 (struct struct_static_04_01 a,
> struct struct_static_04_01 b)
> { return a.s2.s1.a == b.s2.s1.a && a.s2.s1.b == b.s2.s1.b
> && a.s2.s1.c == b.s2.s1.c && a.s2.s1.d == b.s2.s1.d; }
>
> -int __attribute__((noinline,noclone))
> +int __attribute__((noinline)) ATTRIBUTE_NOCLONE
> cmp_struct_static_04_02 (struct struct_static_04_02 a,
> struct struct_static_04_02 b)
> { return a.a == b.a && a.b == b.b && a.c == b.c && a.d == b.d; }
>
> -int __attribute__((noinline,noclone))
> +int __attribute__((noinline)) ATTRIBUTE_NOCLONE
> cmp_struct_static_04_03 (struct struct_static_04_03 a,
> struct struct_static_04_03 b)
> { return a.s4.s3.a == b.s4.s3.a && a.s6.s5.b == b.s6.s5.b
> && a.s8.s7.c == b.s8.s7.c && a.s10.s9.d == b.s10.s9.d; }
>
> -int __attribute__((noinline,noclone))
> +int __attribute__((noinline)) ATTRIBUTE_NOCLONE
> cmp_struct_static_04_04 (struct struct_static_04_04 a,
> struct struct_static_04_04 b)
> { return a.a == b.a && a.b == b.b && a.c == b.c && a.d == b.d; }
>
> -int __attribute__((noinline,noclone))
> +int __attribute__((noinline)) ATTRIBUTE_NOCLONE
> cmp_struct_static_06_01 (struct struct_static_06_01 a,
> struct struct_static_06_01 b)
> { return a.s2.s1.a == b.s2.s1.a && a.s2.s1.b == b.s2.s1.b
> && a.s2.s1.c == b.s2.s1.c && a.s2.s1.d == b.s2.s1.d
> && a.s2.s1.e == b.s2.s1.e && a.f == b.f; }
>
> -int __attribute__((noinline,noclone))
> +int __attribute__((noinline)) ATTRIBUTE_NOCLONE
> cmp_struct_static_06_02 (struct struct_static_06_02 a,
> struct struct_static_06_02 b)
> { return a.a == b.a && a.b == b.b && a.c == b.c && a.d == b.d && a.e == b.e
> && a.f == b.f; }
>
> -int __attribute__((noinline,noclone))
> +int __attribute__((noinline)) ATTRIBUTE_NOCLONE
> cmp_struct_static_06_03 (struct struct_static_06_03 a,
> struct struct_static_06_03 b)
> { return a.s4.s3.a == b.s4.s3.a && a.s6.s5.b == b.s6.s5.b
> && a.s8.s7.c == b.s8.s7.c && a.s10.s9.d == b.s10.s9.d
> && a.s12.s11.e == b.s12.s11.e && a.s12.s11.f == b.s12.s11.f; }
>
> -int __attribute__((noinline,noclone))
> +int __attribute__((noinline)) ATTRIBUTE_NOCLONE
> cmp_struct_static_06_04 (struct struct_static_06_04 a,
> struct struct_static_06_04 b)
> { return a.a == b.a && a.b == b.b && a.c == b.c && a.d == b.d && a.e == b.e
> @@ -366,7 +367,7 @@ int __attribute__((noinline,noclone))
>
> #define CALL_LINE(NAME) val += check_arg_ ## NAME (rtn_str_ ## NAME ())
>
> -int __attribute__((noinline,noclone))
> +int __attribute__((noinline)) ATTRIBUTE_NOCLONE
> call_all ()
> {
> int val = 0;
> @@ -407,7 +408,7 @@ int __attribute__((noinline,noclone))
>
> int volatile v = 1;
>
> -void __attribute__((noinline, noclone))
> +void __attribute__((noinline)) ATTRIBUTE_NOCLONE
> breakpt (void)
> {
> v++;
> diff --git a/gdb/testsuite/gdb.base/vla-optimized-out.c b/gdb/testsuite/gdb.base/vla-optimized-out.c
> index edc2b5e..4520f98 100644
> --- a/gdb/testsuite/gdb.base/vla-optimized-out.c
> +++ b/gdb/testsuite/gdb.base/vla-optimized-out.c
> @@ -18,9 +18,11 @@
> /* The version of this test-case with f1 tagged with noinline only is equivalent
> to gcc/testsuite/gcc.dg/guality/vla-1.c. */
>
> +#include "../lib/noclone.h"
> +
> int
> #ifdef NOCLONE
> -__attribute__((noinline, noclone))
> +__attribute__((noinline)) ATTRIBUTE_NOCLONE
> #else
> __attribute__((noinline))
> #endif
> --
> 1.8.3.1
>
--
Gary Benson - he / him / his
Principal Software Engineer, Red Hat
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Fix testcases using __attribute__((noclone)) with Clang
2020-09-16 16:06 [PATCH] Fix testcases using __attribute__((noclone)) with Clang Gary Benson
2020-09-30 10:02 ` [PING][PATCH] " Gary Benson
2020-10-14 9:27 ` [PING^2][PATCH] " Gary Benson
@ 2020-10-23 13:29 ` Pedro Alves
2020-11-02 11:58 ` Gary Benson
2020-11-02 12:13 ` [PUSHED] " Gary Benson
2 siblings, 2 replies; 6+ messages in thread
From: Pedro Alves @ 2020-10-23 13:29 UTC (permalink / raw)
To: Gary Benson, gdb-patches
On 9/16/20 5:06 PM, Gary Benson via Gdb-patches wrote:
> Hi all,
>
> Clang fails to compile a number of files with the following warning:
> unknown attribute 'noclone' ignored [-Wunknown-attributes]. This
> commit adds a new header, lib/noclone.h, which defines the macro
> ATTRIBUTE_NOCLONE accordingly, and updates the relevant testcases
> to use it.
>
> diff --git a/gdb/testsuite/lib/noclone.h b/gdb/testsuite/lib/noclone.h
> new file mode 100644
> index 0000000..b6a4aa7
> --- /dev/null
> +++ b/gdb/testsuite/lib/noclone.h
I'd think that if you need to handle one attribute,
you'll soon enough need to handle other attributes.
Thus, I'd call this header something more generic like attributes.h.
> +
> +/* Compatibility macro for __attribute__((noclone)). */
> +
> +#ifndef NOCLONE_H
> +#define NOCLONE_H
> +
> +#ifdef __cplusplus
> +extern "C" {
> +#endif
> +
> +#if __has_attribute(noclone)
__has_attribute isn't universally available. For GCC, it was
only added on GCC 5:
https://gcc.gnu.org/gcc-5/changes.html
We support building GDB with GCC 4.8. And the set of compilers the
testsuite can be run against is larger than the set of compilers GDB
builds with -- consider cross compilers for embedded targets,
for example.
So we need to handle __has_attribute not being defined. I think
this would work:
#ifdef __has_attribute
# if !__has_attribute (noclone)
# define ATTRIBUTE_NOCLONE
# endif
#endif
#ifndef ATTRIBUTE_NOCLONE
# define ATTRIBUTE_NOCLONE __attribute__((noclone))
#endif
> +# define ATTRIBUTE_NOCLONE __attribute__((noclone))
> +#else
> +# define ATTRIBUTE_NOCLONE
> +#endif
> +
> +#ifdef __cplusplus
> +}
> +#endif
> +
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Fix testcases using __attribute__((noclone)) with Clang
2020-10-23 13:29 ` [PATCH] " Pedro Alves
@ 2020-11-02 11:58 ` Gary Benson
2020-11-02 12:13 ` [PUSHED] " Gary Benson
1 sibling, 0 replies; 6+ messages in thread
From: Gary Benson @ 2020-11-02 11:58 UTC (permalink / raw)
To: gdb-patches
Clang fails to compile a number of files with the following warning:
unknown attribute 'noclone' ignored [-Wunknown-attributes]. This
commit adds a new header, lib/noclone.h, which defines the macro
ATTRIBUTE_NOCLONE accordingly, and updates the relevant testcases
to use it.
gdb/testsuite/ChangeLog:
* lib/attributes.h: New header.
* gdb.base/backtrace.c: Include the above. Replace
__attribute__(noclone)) with ATTRIBUTE_NOCLONE.
* gdb.base/infcall-nested-structs.c: Likewise.
* gdb.base/vla-optimized-out.c: Likewise.
---
gdb/testsuite/ChangeLog | 8 +++
gdb/testsuite/gdb.base/backtrace.c | 8 +--
gdb/testsuite/gdb.base/infcall-nested-structs.c | 65 +++++++++++++------------
gdb/testsuite/gdb.base/vla-optimized-out.c | 4 +-
gdb/testsuite/lib/attributes.h | 40 +++++++++++++++
5 files changed, 89 insertions(+), 36 deletions(-)
create mode 100644 gdb/testsuite/lib/attributes.h
diff --git a/gdb/testsuite/gdb.base/backtrace.c b/gdb/testsuite/gdb.base/backtrace.c
index bae8b1a..ce63e33 100644
--- a/gdb/testsuite/gdb.base/backtrace.c
+++ b/gdb/testsuite/gdb.base/backtrace.c
@@ -15,19 +15,21 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-int __attribute__((noinline,noclone))
+#include "../lib/attributes.h"
+
+int __attribute__((noinline)) ATTRIBUTE_NOCLONE
baz ()
{
return 0; /* Break here. */
}
-int __attribute__((noinline,noclone))
+int __attribute__((noinline)) ATTRIBUTE_NOCLONE
bar ()
{
return baz ();
}
-int __attribute__((noinline,noclone))
+int __attribute__((noinline)) ATTRIBUTE_NOCLONE
foo ()
{
return bar ();
diff --git a/gdb/testsuite/gdb.base/infcall-nested-structs.c b/gdb/testsuite/gdb.base/infcall-nested-structs.c
index c0c8e19..ee347d4 100644
--- a/gdb/testsuite/gdb.base/infcall-nested-structs.c
+++ b/gdb/testsuite/gdb.base/infcall-nested-structs.c
@@ -33,6 +33,7 @@
in the structs.exp test script. */
#include <string.h>
+#include "../lib/attributes.h"
/* Useful abreviations. */
typedef char tc;
@@ -51,13 +52,13 @@
#endif /* TEST_COMPLEX */
#define MAKE_CHECK_FUNCS(TYPE) \
- int __attribute__((noinline,noclone)) \
+ int __attribute__((noinline)) ATTRIBUTE_NOCLONE \
check_arg_ ## TYPE (struct TYPE arg) \
{ \
return cmp_ ## TYPE (arg, ref_val_ ## TYPE); \
} \
\
- struct TYPE __attribute__((noinline,noclone)) \
+ struct TYPE __attribute__((noinline)) ATTRIBUTE_NOCLONE \
rtn_str_ ## TYPE (void) \
{ \
return (ref_val_ ## TYPE); \
@@ -128,141 +129,141 @@
#endif
-int __attribute__((noinline,noclone))
+int __attribute__((noinline)) ATTRIBUTE_NOCLONE
cmp_struct_01_01 (struct struct_01_01 a, struct struct_01_01 b)
{ return a.s2.s1.a == b.s2.s1.a; }
-int __attribute__((noinline,noclone))
+int __attribute__((noinline)) ATTRIBUTE_NOCLONE
cmp_struct_01_02 (struct struct_01_02 a, struct struct_01_02 b)
{ return a.a == b.a; }
-int __attribute__((noinline,noclone))
+int __attribute__((noinline)) ATTRIBUTE_NOCLONE
cmp_struct_01_03 (struct struct_01_03 a, struct struct_01_03 b)
{ return a.s4.s3.a == b.s4.s3.a; }
-int __attribute__((noinline,noclone))
+int __attribute__((noinline)) ATTRIBUTE_NOCLONE
cmp_struct_01_04 (struct struct_01_04 a, struct struct_01_04 b)
{ return a.a == b.a; }
-int __attribute__((noinline,noclone))
+int __attribute__((noinline)) ATTRIBUTE_NOCLONE
cmp_struct_02_01 (struct struct_02_01 a, struct struct_02_01 b)
{ return a.s2.s1.a == b.s2.s1.a && a.s2.s1.b == b.s2.s1.b; }
-int __attribute__((noinline,noclone))
+int __attribute__((noinline)) ATTRIBUTE_NOCLONE
cmp_struct_02_02 (struct struct_02_02 a, struct struct_02_02 b)
{ return a.a == b.a && a.b == b.b; }
-int __attribute__((noinline,noclone))
+int __attribute__((noinline)) ATTRIBUTE_NOCLONE
cmp_struct_02_03 (struct struct_02_03 a, struct struct_02_03 b)
{ return a.s4.s3.a == b.s4.s3.a && a.s6.s5.b == b.s6.s5.b; }
-int __attribute__((noinline,noclone))
+int __attribute__((noinline)) ATTRIBUTE_NOCLONE
cmp_struct_02_04 (struct struct_02_04 a, struct struct_02_04 b)
{ return a.a == b.a && a.b == b.b; }
-int __attribute__((noinline,noclone))
+int __attribute__((noinline)) ATTRIBUTE_NOCLONE
cmp_struct_04_01 (struct struct_04_01 a, struct struct_04_01 b)
{ return a.s2.s1.a == b.s2.s1.a && a.s2.s1.b == b.s2.s1.b
&& a.s2.s1.c == b.s2.s1.c && a.s2.s1.d == b.s2.s1.d; }
-int __attribute__((noinline,noclone))
+int __attribute__((noinline)) ATTRIBUTE_NOCLONE
cmp_struct_04_02 (struct struct_04_02 a, struct struct_04_02 b)
{ return a.a == b.a && a.b == b.b && a.c == b.c && a.d == b.d; }
-int __attribute__((noinline,noclone))
+int __attribute__((noinline)) ATTRIBUTE_NOCLONE
cmp_struct_04_03 (struct struct_04_03 a, struct struct_04_03 b)
{ return a.s4.s3.a == b.s4.s3.a && a.s6.s5.b == b.s6.s5.b
&& a.s8.s7.c == b.s8.s7.c && a.s10.s9.d == b.s10.s9.d; }
-int __attribute__((noinline,noclone))
+int __attribute__((noinline)) ATTRIBUTE_NOCLONE
cmp_struct_04_04 (struct struct_04_04 a, struct struct_04_04 b)
{ return a.a == b.a && a.b == b.b && a.c == b.c && a.d == b.d; }
-int __attribute__((noinline,noclone))
+int __attribute__((noinline)) ATTRIBUTE_NOCLONE
cmp_struct_05_01 (struct struct_05_01 a, struct struct_05_01 b)
{ return a.s2.s1.a == b.s2.s1.a && a.s2.s1.b == b.s2.s1.b
&& a.s2.s1.c == b.s2.s1.c && a.s2.s1.d == b.s2.s1.d
&& a.s2.s1.e == b.s2.s1.e; }
-int __attribute__((noinline,noclone))
+int __attribute__((noinline)) ATTRIBUTE_NOCLONE
cmp_struct_05_02 (struct struct_05_02 a, struct struct_05_02 b)
{ return a.a == b.a && a.b == b.b && a.c == b.c && a.d == b.d && a.e == b.e; }
-int __attribute__((noinline,noclone))
+int __attribute__((noinline)) ATTRIBUTE_NOCLONE
cmp_struct_05_03 (struct struct_05_03 a, struct struct_05_03 b)
{ return a.s4.s3.a == b.s4.s3.a && a.s6.s5.b == b.s6.s5.b
&& a.s8.s7.c == b.s8.s7.c && a.s10.s9.d == b.s10.s9.d
&& a.s12.s11.e == b.s12.s11.e; }
-int __attribute__((noinline,noclone))
+int __attribute__((noinline)) ATTRIBUTE_NOCLONE
cmp_struct_05_04 (struct struct_05_04 a, struct struct_05_04 b)
{ return a.a == b.a && a.b == b.b && a.c == b.c && a.d == b.d && a.e == b.e; }
#ifdef __cplusplus
-int __attribute__((noinline,noclone))
+int __attribute__((noinline)) ATTRIBUTE_NOCLONE
cmp_struct_static_02_01 (struct struct_static_02_01 a,
struct struct_static_02_01 b)
{ return a.s2.s1.a == b.s2.s1.a && a.s2.s1.b == b.s2.s1.b; }
-int __attribute__((noinline,noclone))
+int __attribute__((noinline)) ATTRIBUTE_NOCLONE
cmp_struct_static_02_02 (struct struct_static_02_02 a,
struct struct_static_02_02 b)
{ return a.a == b.a && a.b == b.b; }
-int __attribute__((noinline,noclone))
+int __attribute__((noinline)) ATTRIBUTE_NOCLONE
cmp_struct_static_02_03 (struct struct_static_02_03 a,
struct struct_static_02_03 b)
{ return a.s4.s3.a == b.s4.s3.a && a.s6.s5.b == b.s6.s5.b; }
-int __attribute__((noinline,noclone))
+int __attribute__((noinline)) ATTRIBUTE_NOCLONE
cmp_struct_static_02_04 (struct struct_static_02_04 a,
struct struct_static_02_04 b)
{ return a.a == b.a && a.b == b.b; }
-int __attribute__((noinline,noclone))
+int __attribute__((noinline)) ATTRIBUTE_NOCLONE
cmp_struct_static_04_01 (struct struct_static_04_01 a,
struct struct_static_04_01 b)
{ return a.s2.s1.a == b.s2.s1.a && a.s2.s1.b == b.s2.s1.b
&& a.s2.s1.c == b.s2.s1.c && a.s2.s1.d == b.s2.s1.d; }
-int __attribute__((noinline,noclone))
+int __attribute__((noinline)) ATTRIBUTE_NOCLONE
cmp_struct_static_04_02 (struct struct_static_04_02 a,
struct struct_static_04_02 b)
{ return a.a == b.a && a.b == b.b && a.c == b.c && a.d == b.d; }
-int __attribute__((noinline,noclone))
+int __attribute__((noinline)) ATTRIBUTE_NOCLONE
cmp_struct_static_04_03 (struct struct_static_04_03 a,
struct struct_static_04_03 b)
{ return a.s4.s3.a == b.s4.s3.a && a.s6.s5.b == b.s6.s5.b
&& a.s8.s7.c == b.s8.s7.c && a.s10.s9.d == b.s10.s9.d; }
-int __attribute__((noinline,noclone))
+int __attribute__((noinline)) ATTRIBUTE_NOCLONE
cmp_struct_static_04_04 (struct struct_static_04_04 a,
struct struct_static_04_04 b)
{ return a.a == b.a && a.b == b.b && a.c == b.c && a.d == b.d; }
-int __attribute__((noinline,noclone))
+int __attribute__((noinline)) ATTRIBUTE_NOCLONE
cmp_struct_static_06_01 (struct struct_static_06_01 a,
struct struct_static_06_01 b)
{ return a.s2.s1.a == b.s2.s1.a && a.s2.s1.b == b.s2.s1.b
&& a.s2.s1.c == b.s2.s1.c && a.s2.s1.d == b.s2.s1.d
&& a.s2.s1.e == b.s2.s1.e && a.f == b.f; }
-int __attribute__((noinline,noclone))
+int __attribute__((noinline)) ATTRIBUTE_NOCLONE
cmp_struct_static_06_02 (struct struct_static_06_02 a,
struct struct_static_06_02 b)
{ return a.a == b.a && a.b == b.b && a.c == b.c && a.d == b.d && a.e == b.e
&& a.f == b.f; }
-int __attribute__((noinline,noclone))
+int __attribute__((noinline)) ATTRIBUTE_NOCLONE
cmp_struct_static_06_03 (struct struct_static_06_03 a,
struct struct_static_06_03 b)
{ return a.s4.s3.a == b.s4.s3.a && a.s6.s5.b == b.s6.s5.b
&& a.s8.s7.c == b.s8.s7.c && a.s10.s9.d == b.s10.s9.d
&& a.s12.s11.e == b.s12.s11.e && a.s12.s11.f == b.s12.s11.f; }
-int __attribute__((noinline,noclone))
+int __attribute__((noinline)) ATTRIBUTE_NOCLONE
cmp_struct_static_06_04 (struct struct_static_06_04 a,
struct struct_static_06_04 b)
{ return a.a == b.a && a.b == b.b && a.c == b.c && a.d == b.d && a.e == b.e
@@ -366,7 +367,7 @@ int __attribute__((noinline,noclone))
#define CALL_LINE(NAME) val += check_arg_ ## NAME (rtn_str_ ## NAME ())
-int __attribute__((noinline,noclone))
+int __attribute__((noinline)) ATTRIBUTE_NOCLONE
call_all ()
{
int val = 0;
@@ -407,7 +408,7 @@ int __attribute__((noinline,noclone))
int volatile v = 1;
-void __attribute__((noinline, noclone))
+void __attribute__((noinline)) ATTRIBUTE_NOCLONE
breakpt (void)
{
v++;
diff --git a/gdb/testsuite/gdb.base/vla-optimized-out.c b/gdb/testsuite/gdb.base/vla-optimized-out.c
index edc2b5e..d21df7a 100644
--- a/gdb/testsuite/gdb.base/vla-optimized-out.c
+++ b/gdb/testsuite/gdb.base/vla-optimized-out.c
@@ -18,9 +18,11 @@
/* The version of this test-case with f1 tagged with noinline only is equivalent
to gcc/testsuite/gcc.dg/guality/vla-1.c. */
+#include "../lib/attributes.h"
+
int
#ifdef NOCLONE
-__attribute__((noinline, noclone))
+__attribute__((noinline)) ATTRIBUTE_NOCLONE
#else
__attribute__((noinline))
#endif
diff --git a/gdb/testsuite/lib/attributes.h b/gdb/testsuite/lib/attributes.h
new file mode 100644
index 0000000..b66567c
--- /dev/null
+++ b/gdb/testsuite/lib/attributes.h
@@ -0,0 +1,40 @@
+/* This file is part of GDB, the GNU debugger.
+
+ Copyright (C) 2020 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* Compatibility macro for __attribute__((noclone)). */
+
+#ifndef ATTRIBUTES_H
+#define ATTRIBUTES_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef __has_attribute
+# if !__has_attribute (noclone)
+# define ATTRIBUTE_NOCLONE
+# endif
+#endif
+#ifndef ATTRIBUTE_NOCLONE
+# define ATTRIBUTE_NOCLONE __attribute__((noclone))
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* ATTRIBUTES_H */
--
1.8.3.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PUSHED] Fix testcases using __attribute__((noclone)) with Clang
2020-10-23 13:29 ` [PATCH] " Pedro Alves
2020-11-02 11:58 ` Gary Benson
@ 2020-11-02 12:13 ` Gary Benson
1 sibling, 0 replies; 6+ messages in thread
From: Gary Benson @ 2020-11-02 12:13 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches
Hi Pedro,
Sorry for the random email I just sent, git-send-email fired it off
before I was ready!
What it *should* have said was:
Thank you for the review. I've updated my patch with your suggestion.
Also, I interpreted your "I think this would work" to mean you hadn't
tested it, so I dug out a copy of GCC 4.8 and checked the preprocessor
conditionals were doing the right thing (they were).
Cheers,
Gary
Pedro Alves wrote:
> On 9/16/20 5:06 PM, Gary Benson via Gdb-patches wrote:
> > Clang fails to compile a number of files with the following warning:
> > unknown attribute 'noclone' ignored [-Wunknown-attributes]. This
> > commit adds a new header, lib/noclone.h, which defines the macro
> > ATTRIBUTE_NOCLONE accordingly, and updates the relevant testcases
> > to use it.
>
> > diff --git a/gdb/testsuite/lib/noclone.h b/gdb/testsuite/lib/noclone.h
> > new file mode 100644
> > index 0000000..b6a4aa7
> > --- /dev/null
> > +++ b/gdb/testsuite/lib/noclone.h
>
> I'd think that if you need to handle one attribute,
> you'll soon enough need to handle other attributes.
> Thus, I'd call this header something more generic like attributes.h.
>
> > +
> > +/* Compatibility macro for __attribute__((noclone)). */
> > +
> > +#ifndef NOCLONE_H
> > +#define NOCLONE_H
> > +
> > +#ifdef __cplusplus
> > +extern "C" {
> > +#endif
> > +
> > +#if __has_attribute(noclone)
>
> __has_attribute isn't universally available. For GCC, it was
> only added on GCC 5:
>
> https://gcc.gnu.org/gcc-5/changes.html
>
> We support building GDB with GCC 4.8. And the set of compilers the
> testsuite can be run against is larger than the set of compilers GDB
> builds with -- consider cross compilers for embedded targets,
> for example.
>
> So we need to handle __has_attribute not being defined. I think
> this would work:
>
> #ifdef __has_attribute
> # if !__has_attribute (noclone)
> # define ATTRIBUTE_NOCLONE
> # endif
> #endif
> #ifndef ATTRIBUTE_NOCLONE
> # define ATTRIBUTE_NOCLONE __attribute__((noclone))
> #endif
>
> > +# define ATTRIBUTE_NOCLONE __attribute__((noclone))
> > +#else
> > +# define ATTRIBUTE_NOCLONE
> > +#endif
> > +
> > +#ifdef __cplusplus
> > +}
> > +#endif
> > +
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-11-02 12:13 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-16 16:06 [PATCH] Fix testcases using __attribute__((noclone)) with Clang Gary Benson
2020-09-30 10:02 ` [PING][PATCH] " Gary Benson
2020-10-14 9:27 ` [PING^2][PATCH] " Gary Benson
2020-10-23 13:29 ` [PATCH] " Pedro Alves
2020-11-02 11:58 ` Gary Benson
2020-11-02 12:13 ` [PUSHED] " Gary Benson
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).