diff mbox series

committed – Re: [Patch] testsuite/lib/gfortran.exp: Add -I for ISO*.h [PR101305, PR101660] (was: Re: [Patch] gfortran.dg/dg.exp: Add libgfortran as -I flag for ISO*.h [PR101305] (was: [PATCH 3/3] [PR libfortran/101305] Fix ISO_Fortran_binding.h paths in g

Message ID 86b8acfb-6d60-aad9-2b47-a313fbe4cfaf@codesourcery.com
State New
Headers show
Series committed – Re: [Patch] testsuite/lib/gfortran.exp: Add -I for ISO*.h [PR101305, PR101660] (was: Re: [Patch] gfortran.dg/dg.exp: Add libgfortran as -I flag for ISO*.h [PR101305] (was: [PATCH 3/3] [PR libfortran/101305] Fix ISO_Fortran_binding.h paths in g | expand

Commit Message

Tobias Burnus Aug. 9, 2021, 10:50 a.m. UTC
Now committed as obvious as https://gcc.gnu.org/r12-2808-g527a1cf32c27a3fbeaf6be7596241570d864cc4c

Follow-up suggestions are welcome. To recap, it changes three things:

* In the testcases, update "..." to "<...>" for the include
* -I $specpath/libgfortran - to find the .h file in the build dir (for in-build-tree testing)
* Update GFORTRAN_UNDER_TEST

The first two are very obvious, the latter applies, when running DejaGNU with, e.g.,
--target_board=unix\{-m32,-m64\}".
Those two multilib configs use different libgfortran build dirs and, hence,
the $specpath/libgfortran differs (e.g. x86.../libgfortran + x86.../32/libgfortran).

That's fine, except that when gfortran_init sets GFORTRAN_UNDER_TEST. That only
happend when it was unset. That's fine, except for multilib test runs, it is not
updated when gfortran_init is called for the next multilib run. Thus, in that case
the previous settings are used. – For the discussion in this thread, this means the
wrong ISO_Fortran_binding.h is read.

Or in previous wording:

On 29.07.21 11:51, Tobias Burnus wrote:
> On 29.07.21 09:09, Jakub Jelinek wrote:
>> On Thu, Jul 29, 2021 at 12:56:32AM +0200, Jakub Jelinek wrote:
>>> On Wed, Jul 28, 2021 at 01:22:53PM +0200, Tobias Burnus wrote:
>>>> gfortran.dg/dg.exp: Add libgfortran as -I flag for ISO*.h [PR101305]
>>> Wouldn't it be better to do that in gcc/testsuite/lib/gfortran.exp
>>> to GFORTRAN_UNDER_TEST there next to
>>> -B$specpath/libgfortran/ ?
>
> I guess so – and that's what I did. However, I had to ensure that it
> gets reset otherwise it picks up the wrong header in multilib runs;
> this also affects the -B$specpath/libgfortran bit, but I think that
> makes sense.
>
>> Though, I guess we need that mostly for the C FE, so perhaps it needs
>> to go
>> at the start of additional_flags=, whether TEST_ALWAYS_FLAGS is empty or
>> not.
>
> For the main testsuite (gcc/testsuite/*fortran*/), I believe the patch
> above is sufficient as everything runs through GFORTRAN_UNDER_TEST.
>
> I am also inclined not to add flags to TEST_ALWAYS_FLAGS which then
> might get applied to other/pure C/C++ tests.
>
> Regarding libgomp: that one uses xgcc for the compilation. I don't
> really see a need to use the Fortran array descriptor from a C program
> in libgomp's testsuite. Thus, I am inclined to ignore libgomp.
> Otherwise, as libgomp does not gfortran_init and handles libraries
> separately, I think the code needs to be put into
> libgomp.*fortran/fortran.exp.
>
> Thoughts? Okay?

Tobias

-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955
diff mbox series

Patch

commit 527a1cf32c27a3fbeaf6be7596241570d864cc4c
Author: Tobias Burnus <tobias@codesourcery.com>
Date:   Mon Aug 9 12:35:23 2021 +0200

    testsuite/lib/gfortran.exp: Add -I for ISO*.h [PR101305, PR101660]
    
    This patch adds -I$specdir/libgfortran to GFORTRAN_UNDER_TEST, when
    set by proc gfortran_init. As the $specdir depends on the multilib
    setting, it has to be re-set for a different multilib; hence, we track
    whether a previous call to gfortran_init set that var or whether it
    was set differently.
    
    gcc/testsuite/
            PR libfortran/101305
            PR fortran/101660
    
            * lib/gfortran.exp (gfortran_init): Add -I $specdir/libgfortran to
            GFORTRAN_UNDER_TEST; update it when set by previous gfortran_init call.
            * gfortran.dg/ISO_Fortran_binding_1.c: Use <...> not "..." for
            ISO_Fortran_binding.h's #include.
            * gfortran.dg/ISO_Fortran_binding_10.c: Likewise.
            * gfortran.dg/ISO_Fortran_binding_11.c: Likewise.
            * gfortran.dg/ISO_Fortran_binding_12.c: Likewise.
            * gfortran.dg/ISO_Fortran_binding_15.c: Likewise.
            * gfortran.dg/ISO_Fortran_binding_16.c: Likewise.
            * gfortran.dg/ISO_Fortran_binding_17.c: Likewise.
            * gfortran.dg/ISO_Fortran_binding_18.c: Likewise.
            * gfortran.dg/ISO_Fortran_binding_3.c: Likewise.
            * gfortran.dg/ISO_Fortran_binding_5.c: Likewise.
            * gfortran.dg/ISO_Fortran_binding_6.c: Likewise.
            * gfortran.dg/ISO_Fortran_binding_7.c: Likewise.
            * gfortran.dg/ISO_Fortran_binding_8.c: Likewise.
            * gfortran.dg/ISO_Fortran_binding_9.c: Likewise.
            * gfortran.dg/PR94327.c: Likewise.
            * gfortran.dg/PR94331.c: Likewise.
            * gfortran.dg/bind_c_array_params_3_aux.c: Likewise.
            * gfortran.dg/iso_fortran_binding_uint8_array_driver.c: Likewise.
            * gfortran.dg/pr93524.c: Likewise.
---
 gcc/testsuite/gfortran.dg/ISO_Fortran_binding_1.c              |  2 +-
 gcc/testsuite/gfortran.dg/ISO_Fortran_binding_10.c             |  2 +-
 gcc/testsuite/gfortran.dg/ISO_Fortran_binding_11.c             |  2 +-
 gcc/testsuite/gfortran.dg/ISO_Fortran_binding_12.c             |  2 +-
 gcc/testsuite/gfortran.dg/ISO_Fortran_binding_15.c             |  2 +-
 gcc/testsuite/gfortran.dg/ISO_Fortran_binding_16.c             |  2 +-
 gcc/testsuite/gfortran.dg/ISO_Fortran_binding_17.c             |  2 +-
 gcc/testsuite/gfortran.dg/ISO_Fortran_binding_18.c             |  2 +-
 gcc/testsuite/gfortran.dg/ISO_Fortran_binding_3.c              |  2 +-
 gcc/testsuite/gfortran.dg/ISO_Fortran_binding_5.c              |  2 +-
 gcc/testsuite/gfortran.dg/ISO_Fortran_binding_6.c              |  2 +-
 gcc/testsuite/gfortran.dg/ISO_Fortran_binding_7.c              |  2 +-
 gcc/testsuite/gfortran.dg/ISO_Fortran_binding_8.c              |  2 +-
 gcc/testsuite/gfortran.dg/ISO_Fortran_binding_9.c              |  2 +-
 gcc/testsuite/gfortran.dg/PR94327.c                            |  2 +-
 gcc/testsuite/gfortran.dg/PR94331.c                            |  2 +-
 gcc/testsuite/gfortran.dg/bind_c_array_params_3_aux.c          |  2 +-
 .../gfortran.dg/iso_fortran_binding_uint8_array_driver.c       |  2 +-
 gcc/testsuite/gfortran.dg/pr93524.c                            |  2 +-
 gcc/testsuite/lib/gfortran.exp                                 | 10 ++++++++--
 20 files changed, 27 insertions(+), 21 deletions(-)

diff --git a/gcc/testsuite/gfortran.dg/ISO_Fortran_binding_1.c b/gcc/testsuite/gfortran.dg/ISO_Fortran_binding_1.c
index bb56ca0e04b..d0d036ae779 100644
--- a/gcc/testsuite/gfortran.dg/ISO_Fortran_binding_1.c
+++ b/gcc/testsuite/gfortran.dg/ISO_Fortran_binding_1.c
@@ -1,6 +1,6 @@ 
 /* Test F2008 18.5: ISO_Fortran_binding.h functions.  */
 
-#include "ISO_Fortran_binding.h"
+#include <ISO_Fortran_binding.h>
 #include <assert.h>
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/gcc/testsuite/gfortran.dg/ISO_Fortran_binding_10.c b/gcc/testsuite/gfortran.dg/ISO_Fortran_binding_10.c
index c3954e4e782..91222fff481 100644
--- a/gcc/testsuite/gfortran.dg/ISO_Fortran_binding_10.c
+++ b/gcc/testsuite/gfortran.dg/ISO_Fortran_binding_10.c
@@ -2,7 +2,7 @@ 
 
 /* Contributed by Reinhold Bader  <Bader@lrz.de> */
 
-#include "ISO_Fortran_binding.h"
+#include <ISO_Fortran_binding.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <stdbool.h>
diff --git a/gcc/testsuite/gfortran.dg/ISO_Fortran_binding_11.c b/gcc/testsuite/gfortran.dg/ISO_Fortran_binding_11.c
index c2d4e11c9d3..e013011a380 100644
--- a/gcc/testsuite/gfortran.dg/ISO_Fortran_binding_11.c
+++ b/gcc/testsuite/gfortran.dg/ISO_Fortran_binding_11.c
@@ -5,7 +5,7 @@  Contributed by Reinhold Bader  <Bader@lrz.de>#include <stdio.h> */
 #include <stdlib.h>
 #include <stddef.h>
 #include <stdio.h>
-#include "ISO_Fortran_binding.h"
+#include <ISO_Fortran_binding.h>
 
 typedef struct
 {
diff --git a/gcc/testsuite/gfortran.dg/ISO_Fortran_binding_12.c b/gcc/testsuite/gfortran.dg/ISO_Fortran_binding_12.c
index 078c5de87d0..0a41576aa5e 100644
--- a/gcc/testsuite/gfortran.dg/ISO_Fortran_binding_12.c
+++ b/gcc/testsuite/gfortran.dg/ISO_Fortran_binding_12.c
@@ -2,7 +2,7 @@ 
 
 #include <stdio.h>
 #include <math.h>
-#include "ISO_Fortran_binding.h"
+#include <ISO_Fortran_binding.h>
 
 /* Contributed by Reinhold Bader  <Bader@lrz.de>  */
 
diff --git a/gcc/testsuite/gfortran.dg/ISO_Fortran_binding_15.c b/gcc/testsuite/gfortran.dg/ISO_Fortran_binding_15.c
index 622f2de6ff3..fc70da4d133 100644
--- a/gcc/testsuite/gfortran.dg/ISO_Fortran_binding_15.c
+++ b/gcc/testsuite/gfortran.dg/ISO_Fortran_binding_15.c
@@ -4,7 +4,7 @@ 
 
 #include <stdlib.h>
 #include <stdio.h>
-#include "ISO_Fortran_binding.h"
+#include <ISO_Fortran_binding.h>
 
 // Prototype for Fortran functions
 extern void Fsub(CFI_cdesc_t *);
diff --git a/gcc/testsuite/gfortran.dg/ISO_Fortran_binding_16.c b/gcc/testsuite/gfortran.dg/ISO_Fortran_binding_16.c
index 50b92ec069c..915b6e7d568 100644
--- a/gcc/testsuite/gfortran.dg/ISO_Fortran_binding_16.c
+++ b/gcc/testsuite/gfortran.dg/ISO_Fortran_binding_16.c
@@ -1,6 +1,6 @@ 
 /* Test the fix for PR92142. */
 
-#include "ISO_Fortran_binding.h"
+#include <ISO_Fortran_binding.h>
 
 #include <stdlib.h>
 
diff --git a/gcc/testsuite/gfortran.dg/ISO_Fortran_binding_17.c b/gcc/testsuite/gfortran.dg/ISO_Fortran_binding_17.c
index b0893cc15e8..fa75268cd26 100644
--- a/gcc/testsuite/gfortran.dg/ISO_Fortran_binding_17.c
+++ b/gcc/testsuite/gfortran.dg/ISO_Fortran_binding_17.c
@@ -2,7 +2,7 @@ 
 
 #include <stdio.h>
 #include <assert.h>
-#include "ISO_Fortran_binding.h"
+#include <ISO_Fortran_binding.h>
 
 void Csub(const CFI_cdesc_t *, size_t, CFI_index_t invalid);
 
diff --git a/gcc/testsuite/gfortran.dg/ISO_Fortran_binding_18.c b/gcc/testsuite/gfortran.dg/ISO_Fortran_binding_18.c
index ef40134fa3c..5a3952ca92e 100644
--- a/gcc/testsuite/gfortran.dg/ISO_Fortran_binding_18.c
+++ b/gcc/testsuite/gfortran.dg/ISO_Fortran_binding_18.c
@@ -1,6 +1,6 @@ 
 #include <stdlib.h>
 #include <string.h>
-#include "ISO_Fortran_binding.h"
+#include <ISO_Fortran_binding.h>
 
 
 extern int do_loop(CFI_cdesc_t* array);
diff --git a/gcc/testsuite/gfortran.dg/ISO_Fortran_binding_3.c b/gcc/testsuite/gfortran.dg/ISO_Fortran_binding_3.c
index 9f35b0dcb80..33d1bc3c7e3 100644
--- a/gcc/testsuite/gfortran.dg/ISO_Fortran_binding_3.c
+++ b/gcc/testsuite/gfortran.dg/ISO_Fortran_binding_3.c
@@ -1,4 +1,4 @@ 
-#include "ISO_Fortran_binding.h"
+#include <ISO_Fortran_binding.h>
 #include <stdio.h>
 #include <stdlib.h>
 
diff --git a/gcc/testsuite/gfortran.dg/ISO_Fortran_binding_5.c b/gcc/testsuite/gfortran.dg/ISO_Fortran_binding_5.c
index 116f548ad99..b18a899ba26 100644
--- a/gcc/testsuite/gfortran.dg/ISO_Fortran_binding_5.c
+++ b/gcc/testsuite/gfortran.dg/ISO_Fortran_binding_5.c
@@ -4,7 +4,7 @@ 
 
 #include <stdio.h>
 #include <math.h>
-#include "ISO_Fortran_binding.h"
+#include <ISO_Fortran_binding.h>
 
 typedef struct {
   int i;
diff --git a/gcc/testsuite/gfortran.dg/ISO_Fortran_binding_6.c b/gcc/testsuite/gfortran.dg/ISO_Fortran_binding_6.c
index 704b27cb28a..c7981c5847a 100644
--- a/gcc/testsuite/gfortran.dg/ISO_Fortran_binding_6.c
+++ b/gcc/testsuite/gfortran.dg/ISO_Fortran_binding_6.c
@@ -4,7 +4,7 @@ 
 
 #include <stdio.h>
 #include <math.h>
-#include "ISO_Fortran_binding.h"
+#include <ISO_Fortran_binding.h>
 
 #define DEBUG 0
 
diff --git a/gcc/testsuite/gfortran.dg/ISO_Fortran_binding_7.c b/gcc/testsuite/gfortran.dg/ISO_Fortran_binding_7.c
index 26b4ab5a015..8162451ca99 100644
--- a/gcc/testsuite/gfortran.dg/ISO_Fortran_binding_7.c
+++ b/gcc/testsuite/gfortran.dg/ISO_Fortran_binding_7.c
@@ -2,7 +2,7 @@ 
 
 /* Contributed by Reinhold Bader  <Bader@lrz.de> */
 
-#include "ISO_Fortran_binding.h"
+#include <ISO_Fortran_binding.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <math.h>
diff --git a/gcc/testsuite/gfortran.dg/ISO_Fortran_binding_8.c b/gcc/testsuite/gfortran.dg/ISO_Fortran_binding_8.c
index a0d1bdc8e83..d3dce3a3472 100644
--- a/gcc/testsuite/gfortran.dg/ISO_Fortran_binding_8.c
+++ b/gcc/testsuite/gfortran.dg/ISO_Fortran_binding_8.c
@@ -2,7 +2,7 @@ 
 
 /* Contributed by Reinhold Bader  <Bader@lrz.de> */
 
-#include "ISO_Fortran_binding.h"
+#include <ISO_Fortran_binding.h>
 #include <stdio.h>
 
 float Cxgl[] = { 1.1, 2.3, 5.1, 4.2 };
diff --git a/gcc/testsuite/gfortran.dg/ISO_Fortran_binding_9.c b/gcc/testsuite/gfortran.dg/ISO_Fortran_binding_9.c
index 632604f5ee8..cb170778642 100644
--- a/gcc/testsuite/gfortran.dg/ISO_Fortran_binding_9.c
+++ b/gcc/testsuite/gfortran.dg/ISO_Fortran_binding_9.c
@@ -2,7 +2,7 @@ 
 
 /* Contributed by Gilles Gouaillardet  <gilles@rist.or.jp> */
 
-#include "ISO_Fortran_binding.h"
+#include <ISO_Fortran_binding.h>
 #include <stdlib.h>
 
 int cdesc_c(CFI_cdesc_t* x, long *expected)
diff --git a/gcc/testsuite/gfortran.dg/PR94327.c b/gcc/testsuite/gfortran.dg/PR94327.c
index 4ce408dbc39..9d226811f58 100644
--- a/gcc/testsuite/gfortran.dg/PR94327.c
+++ b/gcc/testsuite/gfortran.dg/PR94327.c
@@ -4,7 +4,7 @@ 
 #include <stdbool.h>
 #include <stdlib.h>
 
-#include "ISO_Fortran_binding.h"
+#include <ISO_Fortran_binding.h>
 
 bool c_vrfy (const CFI_cdesc_t *restrict);
 
diff --git a/gcc/testsuite/gfortran.dg/PR94331.c b/gcc/testsuite/gfortran.dg/PR94331.c
index 2fbfe0e7144..df571c7583c 100644
--- a/gcc/testsuite/gfortran.dg/PR94331.c
+++ b/gcc/testsuite/gfortran.dg/PR94331.c
@@ -4,7 +4,7 @@ 
 #include <stdbool.h>
 #include <stdlib.h>
 
-#include "ISO_Fortran_binding.h"
+#include <ISO_Fortran_binding.h>
 
 bool c_vrfy (const CFI_cdesc_t *restrict);
 
diff --git a/gcc/testsuite/gfortran.dg/bind_c_array_params_3_aux.c b/gcc/testsuite/gfortran.dg/bind_c_array_params_3_aux.c
index 5176d8b5741..45941853928 100644
--- a/gcc/testsuite/gfortran.dg/bind_c_array_params_3_aux.c
+++ b/gcc/testsuite/gfortran.dg/bind_c_array_params_3_aux.c
@@ -5,7 +5,7 @@ 
 #include <errno.h>
 #include <stdio.h>
 
-#include "ISO_Fortran_binding.h"
+#include <ISO_Fortran_binding.h>
 
 void arr_set_c(CFI_cdesc_t*);
 
diff --git a/gcc/testsuite/gfortran.dg/iso_fortran_binding_uint8_array_driver.c b/gcc/testsuite/gfortran.dg/iso_fortran_binding_uint8_array_driver.c
index bfd567bba95..9c2b5fb721b 100644
--- a/gcc/testsuite/gfortran.dg/iso_fortran_binding_uint8_array_driver.c
+++ b/gcc/testsuite/gfortran.dg/iso_fortran_binding_uint8_array_driver.c
@@ -1,7 +1,7 @@ 
 #include <stdlib.h>
 #include <stdio.h>
 #include <inttypes.h>
-#include "ISO_Fortran_binding.h"
+#include <ISO_Fortran_binding.h>
 
 extern void fsub(CFI_cdesc_t *);
 
diff --git a/gcc/testsuite/gfortran.dg/pr93524.c b/gcc/testsuite/gfortran.dg/pr93524.c
index ba40d007bfb..8a6c06677f2 100644
--- a/gcc/testsuite/gfortran.dg/pr93524.c
+++ b/gcc/testsuite/gfortran.dg/pr93524.c
@@ -2,7 +2,7 @@ 
    sm incorrectly for dimensions > 2.  */
 
 #include <stdlib.h>  // For size_t
-#include "ISO_Fortran_binding.h"
+#include <ISO_Fortran_binding.h>
 
 void my_fortran_sub_1 (CFI_cdesc_t *dv); 
 void my_fortran_sub_2 (CFI_cdesc_t *dv); 
diff --git a/gcc/testsuite/lib/gfortran.exp b/gcc/testsuite/lib/gfortran.exp
index 1e7da1110bc..cae6738b4b8 100644
--- a/gcc/testsuite/lib/gfortran.exp
+++ b/gcc/testsuite/lib/gfortran.exp
@@ -151,6 +151,7 @@  proc gfortran_init { args } {
     global gcc_warning_prefix
     global gcc_error_prefix
     global TEST_ALWAYS_FLAGS
+    global gfortran_init_set_GFORTRAN_UNDER_TEST
 
     # We set LC_ALL and LANG to C so that we get the same error messages as expected.
     setenv LC_ALL C
@@ -166,7 +167,11 @@  proc gfortran_init { args } {
       setenv LANG C.ASCII
     }
 
-    if ![info exists GFORTRAN_UNDER_TEST] then {
+    # GFORTRAN_UNDER_TEST as set below contains $specpath, which depends on
+    # the used multilib config. Thus, its value may need to be reset;
+    # that's tracked via gfortran_init_set_GFORTRAN_UNDER_TEST.
+    if { ![info exists GFORTRAN_UNDER_TEST]
+	 || [info exists gfortran_init_set_GFORTRAN_UNDER_TEST] } then {
 	if [info exists TOOL_EXECUTABLE] {
 	    set GFORTRAN_UNDER_TEST $TOOL_EXECUTABLE
 	} else {
@@ -178,7 +183,8 @@  proc gfortran_init { args } {
 		} else {
 		    set specpath [get_multilibs]
 		}
-		set GFORTRAN_UNDER_TEST [findfile $base_dir/../../gfortran "$base_dir/../../gfortran -B$base_dir/../../ -B$specpath/libgfortran/" [findfile $base_dir/gfortran "$base_dir/gfortran -B$base_dir/" [transform gfortran]]]
+		set gfortran_init_set_GFORTRAN_UNDER_TEST 1
+		set GFORTRAN_UNDER_TEST [findfile $base_dir/../../gfortran "$base_dir/../../gfortran -B$base_dir/../../ -B$specpath/libgfortran/ -I$specpath/libgfortran" [findfile $base_dir/gfortran "$base_dir/gfortran -B$base_dir/" [transform gfortran]]]
 	    }
 	}
     }