]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
fortran: cleanup duplicate tests for c_f_pointer_shape_driver
authorYuao Ma <c8ef@outlook.com>
Mon, 4 Aug 2025 12:19:27 +0000 (20:19 +0800)
committerTobias Burnus <tburnus@baylibre.com>
Wed, 6 Aug 2025 09:15:34 +0000 (11:15 +0200)
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_4_driver.c: Removed.
* gfortran.dg/c_f_pointer_shape_tests_2_driver.c: Renamed to ...
* gfortran.dg/c_f_pointer_shape_tests_driver.c: ... this; format
with gcc style.

gcc/testsuite/gfortran.dg/c_f_pointer_shape_tests_2.f03
gcc/testsuite/gfortran.dg/c_f_pointer_shape_tests_2_driver.c [deleted file]
gcc/testsuite/gfortran.dg/c_f_pointer_shape_tests_4.f03
gcc/testsuite/gfortran.dg/c_f_pointer_shape_tests_4_driver.c [deleted file]
gcc/testsuite/gfortran.dg/c_f_pointer_shape_tests_driver.c [new file with mode: 0644]

index 79cf2c1bae3d24908be17bd133f8d0d26aada4fb..da20835891ff6cc3ec144b26c1287d1aa87ca8c7 100644 (file)
@@ -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 (file)
index 1282beb..0000000
+++ /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;
-}
index 3f60f17e4bb8b63e6c8997316d50dc3bf9301673..519087a2db6d5382fadddc22a14ea783906f0ec4 100644 (file)
@@ -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 (file)
index 1282beb..0000000
+++ /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 (file)
index 0000000..70e7d56
--- /dev/null
@@ -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;
+}