Hi all,
This patch cleans up a duplicate test driver.
Regression-tested. OK for trunk?
Thanks,
Yuao
From f4e821d346652ff4f9ac1a934a6afd019f13e026 Mon Sep 17 00:00:00 2001
From: Yuao Ma <c...@outlook.com>
Date: Mon, 4 Aug 2025 20:19:27 +0800
Subject: [PATCH] fortran: cleanup duplicate tests for
c_f_pointer_shape_driver; nfc
tests_2_driver and tests_4_driver are identical, and tests_4_driver is not used
at all. This patch clean this up, and format the driver with gcc style.
gcc/testsuite/ChangeLog:
* gfortran.dg/c_f_pointer_shape_tests_2.f03: Use the new driver.
* gfortran.dg/c_f_pointer_shape_tests_4.f03: Ditto.
* gfortran.dg/c_f_pointer_shape_tests_2_driver.c: Removed.
* gfortran.dg/c_f_pointer_shape_tests_4_driver.c: Removed.
* gfortran.dg/c_f_pointer_shape_tests_driver.c: New test.
---
.../gfortran.dg/c_f_pointer_shape_tests_2.f03 | 2 +-
.../c_f_pointer_shape_tests_2_driver.c | 46 ------------------
.../gfortran.dg/c_f_pointer_shape_tests_4.f03 | 2 +-
.../c_f_pointer_shape_tests_4_driver.c | 46 ------------------
.../c_f_pointer_shape_tests_driver.c | 47 +++++++++++++++++++
5 files changed, 49 insertions(+), 94 deletions(-)
delete mode 100644 gcc/testsuite/gfortran.dg/c_f_pointer_shape_tests_2_driver.c
delete mode 100644 gcc/testsuite/gfortran.dg/c_f_pointer_shape_tests_4_driver.c
create mode 100644 gcc/testsuite/gfortran.dg/c_f_pointer_shape_tests_driver.c
diff --git a/gcc/testsuite/gfortran.dg/c_f_pointer_shape_tests_2.f03
b/gcc/testsuite/gfortran.dg/c_f_pointer_shape_tests_2.f03
index 79cf2c1bae3..da20835891f 100644
--- a/gcc/testsuite/gfortran.dg/c_f_pointer_shape_tests_2.f03
+++ b/gcc/testsuite/gfortran.dg/c_f_pointer_shape_tests_2.f03
@@ -1,5 +1,5 @@
! { dg-do run }
-! { dg-additional-sources c_f_pointer_shape_tests_2_driver.c }
+! { dg-additional-sources c_f_pointer_shape_tests_driver.c }
! Verify that the optional SHAPE parameter to c_f_pointer can be of any
! valid integer kind. We don't test all kinds here since it would be
! difficult to know what kinds are valid for the architecture we're running on.
diff --git a/gcc/testsuite/gfortran.dg/c_f_pointer_shape_tests_2_driver.c
b/gcc/testsuite/gfortran.dg/c_f_pointer_shape_tests_2_driver.c
deleted file mode 100644
index 1282beb12d7..00000000000
--- a/gcc/testsuite/gfortran.dg/c_f_pointer_shape_tests_2_driver.c
+++ /dev/null
@@ -1,46 +0,0 @@
-#define NUM_ELEMS 10
-#define NUM_ROWS 2
-#define NUM_COLS 3
-
-void test_long_long_1d(int *array, int num_elems);
-void test_long_long_2d(int *array, int num_rows, int num_cols);
-void test_long_1d(int *array, int num_elems);
-void test_int_1d(int *array, int num_elems);
-void test_short_1d(int *array, int num_elems);
-void test_mixed(int *array, int num_elems);
-
-int main(int argc, char **argv)
-{
- int my_array[NUM_ELEMS];
- int my_2d_array[NUM_ROWS][NUM_COLS];
- int i, j;
-
- for(i = 0; i < NUM_ELEMS; i++)
- my_array[i] = i;
-
- for(i = 0; i < NUM_ROWS; i++)
- for(j = 0; j < NUM_COLS; j++)
- my_2d_array[i][j] = (i*NUM_COLS) + j;
-
- /* Test c_f_pointer where SHAPE is of type integer, kind=c_long_long. */
- test_long_long_1d(my_array, NUM_ELEMS);
-
- /* Test c_f_pointer where SHAPE is of type integer, kind=c_long_long.
- The indices are transposed for Fortran. */
- test_long_long_2d(my_2d_array[0], NUM_COLS, NUM_ROWS);
-
- /* Test c_f_pointer where SHAPE is of type integer, kind=c_long. */
- test_long_1d(my_array, NUM_ELEMS);
-
- /* Test c_f_pointer where SHAPE is of type integer, kind=c_int. */
- test_int_1d(my_array, NUM_ELEMS);
-
- /* Test c_f_pointer where SHAPE is of type integer, kind=c_short. */
- test_short_1d(my_array, NUM_ELEMS);
-
- /* Test c_f_pointer where SHAPE is of type integer, kind=c_int and
- kind=c_long_long. */
- test_mixed(my_array, NUM_ELEMS);
-
- return 0;
-}
diff --git a/gcc/testsuite/gfortran.dg/c_f_pointer_shape_tests_4.f03
b/gcc/testsuite/gfortran.dg/c_f_pointer_shape_tests_4.f03
index 3f60f17e4bb..519087a2db6 100644
--- a/gcc/testsuite/gfortran.dg/c_f_pointer_shape_tests_4.f03
+++ b/gcc/testsuite/gfortran.dg/c_f_pointer_shape_tests_4.f03
@@ -1,5 +1,5 @@
! { dg-do run }
-! { dg-additional-sources c_f_pointer_shape_tests_2_driver.c }
+! { dg-additional-sources c_f_pointer_shape_tests_driver.c }
! Verify that the optional SHAPE parameter to c_f_pointer can be of any
! valid integer kind. We don't test all kinds here since it would be
! difficult to know what kinds are valid for the architecture we're running on.
diff --git a/gcc/testsuite/gfortran.dg/c_f_pointer_shape_tests_4_driver.c
b/gcc/testsuite/gfortran.dg/c_f_pointer_shape_tests_4_driver.c
deleted file mode 100644
index 1282beb12d7..00000000000
--- a/gcc/testsuite/gfortran.dg/c_f_pointer_shape_tests_4_driver.c
+++ /dev/null
@@ -1,46 +0,0 @@
-#define NUM_ELEMS 10
-#define NUM_ROWS 2
-#define NUM_COLS 3
-
-void test_long_long_1d(int *array, int num_elems);
-void test_long_long_2d(int *array, int num_rows, int num_cols);
-void test_long_1d(int *array, int num_elems);
-void test_int_1d(int *array, int num_elems);
-void test_short_1d(int *array, int num_elems);
-void test_mixed(int *array, int num_elems);
-
-int main(int argc, char **argv)
-{
- int my_array[NUM_ELEMS];
- int my_2d_array[NUM_ROWS][NUM_COLS];
- int i, j;
-
- for(i = 0; i < NUM_ELEMS; i++)
- my_array[i] = i;
-
- for(i = 0; i < NUM_ROWS; i++)
- for(j = 0; j < NUM_COLS; j++)
- my_2d_array[i][j] = (i*NUM_COLS) + j;
-
- /* Test c_f_pointer where SHAPE is of type integer, kind=c_long_long. */
- test_long_long_1d(my_array, NUM_ELEMS);
-
- /* Test c_f_pointer where SHAPE is of type integer, kind=c_long_long.
- The indices are transposed for Fortran. */
- test_long_long_2d(my_2d_array[0], NUM_COLS, NUM_ROWS);
-
- /* Test c_f_pointer where SHAPE is of type integer, kind=c_long. */
- test_long_1d(my_array, NUM_ELEMS);
-
- /* Test c_f_pointer where SHAPE is of type integer, kind=c_int. */
- test_int_1d(my_array, NUM_ELEMS);
-
- /* Test c_f_pointer where SHAPE is of type integer, kind=c_short. */
- test_short_1d(my_array, NUM_ELEMS);
-
- /* Test c_f_pointer where SHAPE is of type integer, kind=c_int and
- kind=c_long_long. */
- test_mixed(my_array, NUM_ELEMS);
-
- return 0;
-}
diff --git a/gcc/testsuite/gfortran.dg/c_f_pointer_shape_tests_driver.c
b/gcc/testsuite/gfortran.dg/c_f_pointer_shape_tests_driver.c
new file mode 100644
index 00000000000..70e7d565320
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/c_f_pointer_shape_tests_driver.c
@@ -0,0 +1,47 @@
+#define NUM_ELEMS 10
+#define NUM_ROWS 2
+#define NUM_COLS 3
+
+void test_long_long_1d (int *array, int num_elems);
+void test_long_long_2d (int *array, int num_rows, int num_cols);
+void test_long_1d (int *array, int num_elems);
+void test_int_1d (int *array, int num_elems);
+void test_short_1d (int *array, int num_elems);
+void test_mixed (int *array, int num_elems);
+
+int
+main (int argc, char **argv)
+{
+ int my_array[NUM_ELEMS];
+ int my_2d_array[NUM_ROWS][NUM_COLS];
+ int i, j;
+
+ for (i = 0; i < NUM_ELEMS; i++)
+ my_array[i] = i;
+
+ for (i = 0; i < NUM_ROWS; i++)
+ for (j = 0; j < NUM_COLS; j++)
+ my_2d_array[i][j] = (i * NUM_COLS) + j;
+
+ /* Test c_f_pointer where SHAPE is of type integer, kind=c_long_long. */
+ test_long_long_1d (my_array, NUM_ELEMS);
+
+ /* Test c_f_pointer where SHAPE is of type integer, kind=c_long_long.
+ The indices are transposed for Fortran. */
+ test_long_long_2d (my_2d_array[0], NUM_COLS, NUM_ROWS);
+
+ /* Test c_f_pointer where SHAPE is of type integer, kind=c_long. */
+ test_long_1d (my_array, NUM_ELEMS);
+
+ /* Test c_f_pointer where SHAPE is of type integer, kind=c_int. */
+ test_int_1d (my_array, NUM_ELEMS);
+
+ /* Test c_f_pointer where SHAPE is of type integer, kind=c_short. */
+ test_short_1d (my_array, NUM_ELEMS);
+
+ /* Test c_f_pointer where SHAPE is of type integer, kind=c_int and
+ kind=c_long_long. */
+ test_mixed (my_array, NUM_ELEMS);
+
+ return 0;
+}
--
2.43.0