Re: [PR100127] Test for coroutine header in clang-compatible tests

2023-02-27 Thread Mike Stump via Gcc-patches
On Feb 22, 2023, at 12:04 PM, Alexandre Oliva  wrote:
> 
> That would change what gets tested with clang, I suppose, but I hope
> that's for the better.  I wondered what to do at the #else above, and
> decided to spell it a little differently.  Retested on x86_64-linux-gnu
> (trunk) and arm-vxworks7r2 (gcc-12), ok to install?

Ok.


Re: [PR100127] Test for coroutine header in clang-compatible tests

2023-02-22 Thread Alexandre Oliva via Gcc-patches
On Feb 17, 2023, Iain Sandoe  wrote:

> As a matter of interest, do you know of any other compiler claiming 
> “__clang__” (I have
> treated that as safe so far).

We've had (or found it more convenient, not sure) to do that to gcc on
some recent combinations of version and target of vxworks, for one.

>> Use a __has_include feature test instead.

> I think we need to do

> #if __has_include()
> …
> #elif __has_include()
> …

> because newer clang has the include in the standard place.

That would change what gets tested with clang, I suppose, but I hope
that's for the better.  I wondered what to do at the #else above, and
decided to spell it a little differently.  Retested on x86_64-linux-gnu
(trunk) and arm-vxworks7r2 (gcc-12), ok to install?


[PR100127] Test for coroutine header in clang-compatible tests

From: Alexandre Oliva 

The test is compatible with clang as well as gcc, but ISTM that
testing for the __clang__ macro is just as potentially error-prone as
macros that used to be GCC-specific are now defined in compilers that
aim for GCC compatibility.  Use a __has_include feature test instead.


for  gcc/testsuite/ChangeLog

PR c++/100127
* g++.dg/coroutines/pr100127.C: Test for header rather than
compiler macro.
---
 gcc/testsuite/g++.dg/coroutines/pr100127.C   |3 ++-
 gcc/testsuite/g++.dg/coroutines/pr100772-a.C |3 ++-
 gcc/testsuite/g++.dg/coroutines/pr100772-b.C |3 ++-
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/gcc/testsuite/g++.dg/coroutines/pr100127.C 
b/gcc/testsuite/g++.dg/coroutines/pr100127.C
index 374cd710077af..5879fd0bcc595 100644
--- a/gcc/testsuite/g++.dg/coroutines/pr100127.C
+++ b/gcc/testsuite/g++.dg/coroutines/pr100127.C
@@ -1,4 +1,5 @@
-#ifdef __clang__
+#if !__has_include() \
+  && __has_include() // for __clang__
 #include 
 namespace std {
   using namespace std::experimental;
diff --git a/gcc/testsuite/g++.dg/coroutines/pr100772-a.C 
b/gcc/testsuite/g++.dg/coroutines/pr100772-a.C
index a325d384fc390..06e705b0c65a0 100644
--- a/gcc/testsuite/g++.dg/coroutines/pr100772-a.C
+++ b/gcc/testsuite/g++.dg/coroutines/pr100772-a.C
@@ -1,5 +1,6 @@
 //  { dg-additional-options "-fsyntax-only " }
-#ifdef __clang__
+#if !__has_include() \
+  && __has_include() // for __clang__
 #include 
 namespace std {
   using namespace std::experimental;
diff --git a/gcc/testsuite/g++.dg/coroutines/pr100772-b.C 
b/gcc/testsuite/g++.dg/coroutines/pr100772-b.C
index 6cdf8d1e529e5..4ef80a9959490 100644
--- a/gcc/testsuite/g++.dg/coroutines/pr100772-b.C
+++ b/gcc/testsuite/g++.dg/coroutines/pr100772-b.C
@@ -1,4 +1,5 @@
-#ifdef __clang__
+#if !__has_include() \
+  && __has_include() // for __clang__
 #include 
 namespace std {
   using namespace std::experimental;


-- 
Alexandre Oliva, happy hackerhttps://FSFLA.org/blogs/lxo/
   Free Software Activist   GNU Toolchain Engineer
Disinformation flourishes because many people care deeply about injustice
but very few check the facts.  Ask me about <https://stallmansupport.org>


Re: [PR100127] Test for coroutine header in clang-compatible tests

2023-02-17 Thread Iain Sandoe
Hi,

> On 17 Feb 2023, at 06:42, Alexandre Oliva via Gcc-patches 
>  wrote:
> 
> 
> The test is compatible with clang as well as gcc, but ISTM that
> testing for the __clang__ macro is just as potentially error-prone as
> macros that used to be GCC-specific are now defined in compilers that
> aim for GCC compatibility.

It remains useful to be able to check tests on both compilers.

As a matter of interest, do you know of any other compiler claiming “__clang__” 
(I have
treated that as safe so far).

>  Use a __has_include feature test instead.

I think we need to do

#if __has_include()
…
#elif __has_include()
…

because newer clang has the include in the standard place.
Iain

> 
> Regstrapped on x86_64-linux-gnu.
> Tested on arm-vxworks7 (gcc-12) and arm-eabi (trunk).  Ok to install?
> 
> for  gcc/testsuite/ChangeLog
> 
>   PR c++/100127
>   * g++.dg/coroutines/pr100127.C: Test for header rather than
>   compiler macro.
> ---
> gcc/testsuite/g++.dg/coroutines/pr100127.C   |2 +-
> gcc/testsuite/g++.dg/coroutines/pr100772-a.C |2 +-
> gcc/testsuite/g++.dg/coroutines/pr100772-b.C |2 +-
> 3 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/gcc/testsuite/g++.dg/coroutines/pr100127.C 
> b/gcc/testsuite/g++.dg/coroutines/pr100127.C
> index 374cd710077af..1eaa72ff0acdd 100644
> --- a/gcc/testsuite/g++.dg/coroutines/pr100127.C
> +++ b/gcc/testsuite/g++.dg/coroutines/pr100127.C
> @@ -1,4 +1,4 @@
> -#ifdef __clang__
> +#if __has_include() // for __clang__
> #include 
> namespace std {
>   using namespace std::experimental;
> diff --git a/gcc/testsuite/g++.dg/coroutines/pr100772-a.C 
> b/gcc/testsuite/g++.dg/coroutines/pr100772-a.C
> index a325d384fc390..724c377c82e5b 100644
> --- a/gcc/testsuite/g++.dg/coroutines/pr100772-a.C
> +++ b/gcc/testsuite/g++.dg/coroutines/pr100772-a.C
> @@ -1,5 +1,5 @@
> //  { dg-additional-options "-fsyntax-only " }
> -#ifdef __clang__
> +#if __has_include() // for __clang__
> #include 
> namespace std {
>   using namespace std::experimental;
> diff --git a/gcc/testsuite/g++.dg/coroutines/pr100772-b.C 
> b/gcc/testsuite/g++.dg/coroutines/pr100772-b.C
> index 6cdf8d1e529e5..4cf31e5f9e0c2 100644
> --- a/gcc/testsuite/g++.dg/coroutines/pr100772-b.C
> +++ b/gcc/testsuite/g++.dg/coroutines/pr100772-b.C
> @@ -1,4 +1,4 @@
> -#ifdef __clang__
> +#if __has_include() // for __clang__
> #include 
> namespace std {
>   using namespace std::experimental;
> 
> -- 
> Alexandre Oliva, happy hackerhttps://FSFLA.org/blogs/lxo/
>   Free Software Activist   GNU Toolchain Engineer
> Disinformation flourishes because many people care deeply about injustice
> but very few check the facts.  Ask me about 



[PR100127] Test for coroutine header in clang-compatible tests

2023-02-16 Thread Alexandre Oliva via Gcc-patches


The test is compatible with clang as well as gcc, but ISTM that
testing for the __clang__ macro is just as potentially error-prone as
macros that used to be GCC-specific are now defined in compilers that
aim for GCC compatibility.  Use a __has_include feature test instead.

Regstrapped on x86_64-linux-gnu.
Tested on arm-vxworks7 (gcc-12) and arm-eabi (trunk).  Ok to install?

for  gcc/testsuite/ChangeLog

PR c++/100127
* g++.dg/coroutines/pr100127.C: Test for header rather than
compiler macro.
---
 gcc/testsuite/g++.dg/coroutines/pr100127.C   |2 +-
 gcc/testsuite/g++.dg/coroutines/pr100772-a.C |2 +-
 gcc/testsuite/g++.dg/coroutines/pr100772-b.C |2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/gcc/testsuite/g++.dg/coroutines/pr100127.C 
b/gcc/testsuite/g++.dg/coroutines/pr100127.C
index 374cd710077af..1eaa72ff0acdd 100644
--- a/gcc/testsuite/g++.dg/coroutines/pr100127.C
+++ b/gcc/testsuite/g++.dg/coroutines/pr100127.C
@@ -1,4 +1,4 @@
-#ifdef __clang__
+#if __has_include() // for __clang__
 #include 
 namespace std {
   using namespace std::experimental;
diff --git a/gcc/testsuite/g++.dg/coroutines/pr100772-a.C 
b/gcc/testsuite/g++.dg/coroutines/pr100772-a.C
index a325d384fc390..724c377c82e5b 100644
--- a/gcc/testsuite/g++.dg/coroutines/pr100772-a.C
+++ b/gcc/testsuite/g++.dg/coroutines/pr100772-a.C
@@ -1,5 +1,5 @@
 //  { dg-additional-options "-fsyntax-only " }
-#ifdef __clang__
+#if __has_include() // for __clang__
 #include 
 namespace std {
   using namespace std::experimental;
diff --git a/gcc/testsuite/g++.dg/coroutines/pr100772-b.C 
b/gcc/testsuite/g++.dg/coroutines/pr100772-b.C
index 6cdf8d1e529e5..4cf31e5f9e0c2 100644
--- a/gcc/testsuite/g++.dg/coroutines/pr100772-b.C
+++ b/gcc/testsuite/g++.dg/coroutines/pr100772-b.C
@@ -1,4 +1,4 @@
-#ifdef __clang__
+#if __has_include() // for __clang__
 #include 
 namespace std {
   using namespace std::experimental;

-- 
Alexandre Oliva, happy hackerhttps://FSFLA.org/blogs/lxo/
   Free Software Activist   GNU Toolchain Engineer
Disinformation flourishes because many people care deeply about injustice
but very few check the facts.  Ask me about