diff mbox series

[3/4] Add 'c-c++-common/initpri1-split.c': 'c-c++-common/initpri1.c' split into separate translation units

Message ID 20240604183051.1406924-4-tschwinge@baylibre.com
State New
Headers show
Series [1/4] Consolidate similar C/C++ test cases for 'constructor', 'destructor' function attributes with priority | expand

Commit Message

Thomas Schwinge June 4, 2024, 6:30 p.m. UTC
gcc/testsuite/
	* c-c++-common/initpri1.c: Split into...
	* c-c++-common/initpri1_part_c1.c: ... this, and...
	* c-c++-common/initpri1_part_c2.c: ... this, and...
	* c-c++-common/initpri1_part_c3.c: ... this, and...
	* c-c++-common/initpri1_part_cd4.c: ... this, and...
	* c-c++-common/initpri1_part_d1.c: ... this, and...
	* c-c++-common/initpri1_part_d2.c: ... this, and...
	* c-c++-common/initpri1_part_d3.c: ... this, and...
	* c-c++-common/initpri1_part_main.c: ... this part.
	* c-c++-common/initpri1-split.c: New.
---
 .../{initpri1.c => initpri1-split.c}          | 60 +--------------
 gcc/testsuite/c-c++-common/initpri1.c         | 73 ++++---------------
 .../{initpri1.c => initpri1_part_c1.c}        | 54 +-------------
 .../{initpri1.c => initpri1_part_c2.c}        | 54 +-------------
 .../{initpri1.c => initpri1_part_c3.c}        | 54 +-------------
 .../{initpri1.c => initpri1_part_cd4.c}       | 54 +-------------
 .../{initpri1.c => initpri1_part_d1.c}        | 54 +-------------
 .../{initpri1.c => initpri1_part_d2.c}        | 54 +-------------
 .../{initpri1.c => initpri1_part_d3.c}        | 53 +-------------
 .../{initpri1.c => initpri1_part_main.c}      | 50 +------------
 10 files changed, 33 insertions(+), 527 deletions(-)
 copy gcc/testsuite/c-c++-common/{initpri1.c => initpri1-split.c} (14%)
 copy gcc/testsuite/c-c++-common/{initpri1.c => initpri1_part_c1.c} (20%)
 copy gcc/testsuite/c-c++-common/{initpri1.c => initpri1_part_c2.c} (20%)
 copy gcc/testsuite/c-c++-common/{initpri1.c => initpri1_part_c3.c} (20%)
 copy gcc/testsuite/c-c++-common/{initpri1.c => initpri1_part_cd4.c} (22%)
 copy gcc/testsuite/c-c++-common/{initpri1.c => initpri1_part_d1.c} (20%)
 copy gcc/testsuite/c-c++-common/{initpri1.c => initpri1_part_d2.c} (20%)
 copy gcc/testsuite/c-c++-common/{initpri1.c => initpri1_part_d3.c} (23%)
 copy gcc/testsuite/c-c++-common/{initpri1.c => initpri1_part_main.c} (21%)
diff mbox series

Patch

diff --git a/gcc/testsuite/c-c++-common/initpri1.c b/gcc/testsuite/c-c++-common/initpri1-split.c
similarity index 14%
copy from gcc/testsuite/c-c++-common/initpri1.c
copy to gcc/testsuite/c-c++-common/initpri1-split.c
index 387f2a39658..11755ee9f6a 100644
--- a/gcc/testsuite/c-c++-common/initpri1.c
+++ b/gcc/testsuite/c-c++-common/initpri1-split.c
@@ -1,61 +1,3 @@ 
 /* { dg-do run { target init_priority } } */
 /* Via the magic string "-std=*++" indicate that testing one (the default) C++ standard is sufficient.  */
-
-int i;
-int j;
-
-void c1() __attribute__((constructor (500)));
-void c2() __attribute__((constructor (700)));
-void c3() __attribute__((constructor (600)));
-
-void c1() {
-  if (i++ != 0)
-    __builtin_abort ();
-}
-
-void c2() {
-  if (i++ != 2)
-    __builtin_abort ();
-}
-
-void c3() {
-  if (i++ != 1)
-    __builtin_abort ();
-}
-
-void d1() __attribute__((destructor (500)));
-void d2() __attribute__((destructor (700)));
-void d3() __attribute__((destructor (600)));
-
-void d1() {
-  if (--i != 0)
-    __builtin_abort ();
-}
-
-void d2() {
-  if (--i != 2)
-    __builtin_abort ();
-}
-
-void d3() {
-  if (j != 2)
-    __builtin_abort ();
-  if (--i != 1)
-    __builtin_abort ();
-}
-
-void cd4() __attribute__((constructor (800), destructor (800)));
-
-void cd4() {
-  if (i != 3)
-    __builtin_abort ();
-  ++j;
-}
-
-int main () {
-  if (i != 3)
-    return 1;
-  if (j != 1)
-    __builtin_abort ();
-  return 0;
-}
+/* { dg-additional-sources {initpri1_part_c1.c initpri1_part_c2.c initpri1_part_c3.c initpri1_part_d1.c initpri1_part_d2.c initpri1_part_d3.c initpri1_part_cd4.c initpri1_part_main.c} } */
diff --git a/gcc/testsuite/c-c++-common/initpri1.c b/gcc/testsuite/c-c++-common/initpri1.c
index 387f2a39658..f50137a489b 100644
--- a/gcc/testsuite/c-c++-common/initpri1.c
+++ b/gcc/testsuite/c-c++-common/initpri1.c
@@ -1,61 +1,18 @@ 
 /* { dg-do run { target init_priority } } */
 /* Via the magic string "-std=*++" indicate that testing one (the default) C++ standard is sufficient.  */
 
-int i;
-int j;
-
-void c1() __attribute__((constructor (500)));
-void c2() __attribute__((constructor (700)));
-void c3() __attribute__((constructor (600)));
-
-void c1() {
-  if (i++ != 0)
-    __builtin_abort ();
-}
-
-void c2() {
-  if (i++ != 2)
-    __builtin_abort ();
-}
-
-void c3() {
-  if (i++ != 1)
-    __builtin_abort ();
-}
-
-void d1() __attribute__((destructor (500)));
-void d2() __attribute__((destructor (700)));
-void d3() __attribute__((destructor (600)));
-
-void d1() {
-  if (--i != 0)
-    __builtin_abort ();
-}
-
-void d2() {
-  if (--i != 2)
-    __builtin_abort ();
-}
-
-void d3() {
-  if (j != 2)
-    __builtin_abort ();
-  if (--i != 1)
-    __builtin_abort ();
-}
-
-void cd4() __attribute__((constructor (800), destructor (800)));
-
-void cd4() {
-  if (i != 3)
-    __builtin_abort ();
-  ++j;
-}
-
-int main () {
-  if (i != 3)
-    return 1;
-  if (j != 1)
-    __builtin_abort ();
-  return 0;
-}
+#include "initpri1_part_c1.c"
+
+#include "initpri1_part_c2.c"
+
+#include "initpri1_part_c3.c"
+
+#include "initpri1_part_d1.c"
+
+#include "initpri1_part_d2.c"
+
+#include "initpri1_part_d3.c"
+
+#include "initpri1_part_cd4.c"
+
+#include "initpri1_part_main.c"
diff --git a/gcc/testsuite/c-c++-common/initpri1.c b/gcc/testsuite/c-c++-common/initpri1_part_c1.c
similarity index 20%
copy from gcc/testsuite/c-c++-common/initpri1.c
copy to gcc/testsuite/c-c++-common/initpri1_part_c1.c
index 387f2a39658..0f85a2e6cb1 100644
--- a/gcc/testsuite/c-c++-common/initpri1.c
+++ b/gcc/testsuite/c-c++-common/initpri1_part_c1.c
@@ -1,61 +1,11 @@ 
-/* { dg-do run { target init_priority } } */
+/* { dg-skip-if part { *-*-* } } */
 /* Via the magic string "-std=*++" indicate that testing one (the default) C++ standard is sufficient.  */
 
-int i;
-int j;
+extern int i;
 
 void c1() __attribute__((constructor (500)));
-void c2() __attribute__((constructor (700)));
-void c3() __attribute__((constructor (600)));
 
 void c1() {
   if (i++ != 0)
     __builtin_abort ();
 }
-
-void c2() {
-  if (i++ != 2)
-    __builtin_abort ();
-}
-
-void c3() {
-  if (i++ != 1)
-    __builtin_abort ();
-}
-
-void d1() __attribute__((destructor (500)));
-void d2() __attribute__((destructor (700)));
-void d3() __attribute__((destructor (600)));
-
-void d1() {
-  if (--i != 0)
-    __builtin_abort ();
-}
-
-void d2() {
-  if (--i != 2)
-    __builtin_abort ();
-}
-
-void d3() {
-  if (j != 2)
-    __builtin_abort ();
-  if (--i != 1)
-    __builtin_abort ();
-}
-
-void cd4() __attribute__((constructor (800), destructor (800)));
-
-void cd4() {
-  if (i != 3)
-    __builtin_abort ();
-  ++j;
-}
-
-int main () {
-  if (i != 3)
-    return 1;
-  if (j != 1)
-    __builtin_abort ();
-  return 0;
-}
diff --git a/gcc/testsuite/c-c++-common/initpri1.c b/gcc/testsuite/c-c++-common/initpri1_part_c2.c
similarity index 20%
copy from gcc/testsuite/c-c++-common/initpri1.c
copy to gcc/testsuite/c-c++-common/initpri1_part_c2.c
index 387f2a39658..e8c556aab17 100644
--- a/gcc/testsuite/c-c++-common/initpri1.c
+++ b/gcc/testsuite/c-c++-common/initpri1_part_c2.c
@@ -1,61 +1,11 @@ 
-/* { dg-do run { target init_priority } } */
+/* { dg-skip-if part { *-*-* } } */
 /* Via the magic string "-std=*++" indicate that testing one (the default) C++ standard is sufficient.  */
 
-int i;
-int j;
+extern int i;
 
-void c1() __attribute__((constructor (500)));
 void c2() __attribute__((constructor (700)));
-void c3() __attribute__((constructor (600)));
-
-void c1() {
-  if (i++ != 0)
-    __builtin_abort ();
-}
 
 void c2() {
   if (i++ != 2)
     __builtin_abort ();
 }
-
-void c3() {
-  if (i++ != 1)
-    __builtin_abort ();
-}
-
-void d1() __attribute__((destructor (500)));
-void d2() __attribute__((destructor (700)));
-void d3() __attribute__((destructor (600)));
-
-void d1() {
-  if (--i != 0)
-    __builtin_abort ();
-}
-
-void d2() {
-  if (--i != 2)
-    __builtin_abort ();
-}
-
-void d3() {
-  if (j != 2)
-    __builtin_abort ();
-  if (--i != 1)
-    __builtin_abort ();
-}
-
-void cd4() __attribute__((constructor (800), destructor (800)));
-
-void cd4() {
-  if (i != 3)
-    __builtin_abort ();
-  ++j;
-}
-
-int main () {
-  if (i != 3)
-    return 1;
-  if (j != 1)
-    __builtin_abort ();
-  return 0;
-}
diff --git a/gcc/testsuite/c-c++-common/initpri1.c b/gcc/testsuite/c-c++-common/initpri1_part_c3.c
similarity index 20%
copy from gcc/testsuite/c-c++-common/initpri1.c
copy to gcc/testsuite/c-c++-common/initpri1_part_c3.c
index 387f2a39658..70880882ce3 100644
--- a/gcc/testsuite/c-c++-common/initpri1.c
+++ b/gcc/testsuite/c-c++-common/initpri1_part_c3.c
@@ -1,61 +1,11 @@ 
-/* { dg-do run { target init_priority } } */
+/* { dg-skip-if part { *-*-* } } */
 /* Via the magic string "-std=*++" indicate that testing one (the default) C++ standard is sufficient.  */
 
-int i;
-int j;
+extern int i;
 
-void c1() __attribute__((constructor (500)));
-void c2() __attribute__((constructor (700)));
 void c3() __attribute__((constructor (600)));
 
-void c1() {
-  if (i++ != 0)
-    __builtin_abort ();
-}
-
-void c2() {
-  if (i++ != 2)
-    __builtin_abort ();
-}
-
 void c3() {
   if (i++ != 1)
     __builtin_abort ();
 }
-
-void d1() __attribute__((destructor (500)));
-void d2() __attribute__((destructor (700)));
-void d3() __attribute__((destructor (600)));
-
-void d1() {
-  if (--i != 0)
-    __builtin_abort ();
-}
-
-void d2() {
-  if (--i != 2)
-    __builtin_abort ();
-}
-
-void d3() {
-  if (j != 2)
-    __builtin_abort ();
-  if (--i != 1)
-    __builtin_abort ();
-}
-
-void cd4() __attribute__((constructor (800), destructor (800)));
-
-void cd4() {
-  if (i != 3)
-    __builtin_abort ();
-  ++j;
-}
-
-int main () {
-  if (i != 3)
-    return 1;
-  if (j != 1)
-    __builtin_abort ();
-  return 0;
-}
diff --git a/gcc/testsuite/c-c++-common/initpri1.c b/gcc/testsuite/c-c++-common/initpri1_part_cd4.c
similarity index 22%
copy from gcc/testsuite/c-c++-common/initpri1.c
copy to gcc/testsuite/c-c++-common/initpri1_part_cd4.c
index 387f2a39658..b67ff90d9fe 100644
--- a/gcc/testsuite/c-c++-common/initpri1.c
+++ b/gcc/testsuite/c-c++-common/initpri1_part_cd4.c
@@ -1,48 +1,8 @@ 
-/* { dg-do run { target init_priority } } */
+/* { dg-skip-if part { *-*-* } } */
 /* Via the magic string "-std=*++" indicate that testing one (the default) C++ standard is sufficient.  */
 
-int i;
-int j;
-
-void c1() __attribute__((constructor (500)));
-void c2() __attribute__((constructor (700)));
-void c3() __attribute__((constructor (600)));
-
-void c1() {
-  if (i++ != 0)
-    __builtin_abort ();
-}
-
-void c2() {
-  if (i++ != 2)
-    __builtin_abort ();
-}
-
-void c3() {
-  if (i++ != 1)
-    __builtin_abort ();
-}
-
-void d1() __attribute__((destructor (500)));
-void d2() __attribute__((destructor (700)));
-void d3() __attribute__((destructor (600)));
-
-void d1() {
-  if (--i != 0)
-    __builtin_abort ();
-}
-
-void d2() {
-  if (--i != 2)
-    __builtin_abort ();
-}
-
-void d3() {
-  if (j != 2)
-    __builtin_abort ();
-  if (--i != 1)
-    __builtin_abort ();
-}
+extern int i;
+extern int j;
 
 void cd4() __attribute__((constructor (800), destructor (800)));
 
@@ -51,11 +11,3 @@  void cd4() {
     __builtin_abort ();
   ++j;
 }
-
-int main () {
-  if (i != 3)
-    return 1;
-  if (j != 1)
-    __builtin_abort ();
-  return 0;
-}
diff --git a/gcc/testsuite/c-c++-common/initpri1.c b/gcc/testsuite/c-c++-common/initpri1_part_d1.c
similarity index 20%
copy from gcc/testsuite/c-c++-common/initpri1.c
copy to gcc/testsuite/c-c++-common/initpri1_part_d1.c
index 387f2a39658..099df37e97c 100644
--- a/gcc/testsuite/c-c++-common/initpri1.c
+++ b/gcc/testsuite/c-c++-common/initpri1_part_d1.c
@@ -1,61 +1,11 @@ 
-/* { dg-do run { target init_priority } } */
+/* { dg-skip-if part { *-*-* } } */
 /* Via the magic string "-std=*++" indicate that testing one (the default) C++ standard is sufficient.  */
 
-int i;
-int j;
-
-void c1() __attribute__((constructor (500)));
-void c2() __attribute__((constructor (700)));
-void c3() __attribute__((constructor (600)));
-
-void c1() {
-  if (i++ != 0)
-    __builtin_abort ();
-}
-
-void c2() {
-  if (i++ != 2)
-    __builtin_abort ();
-}
-
-void c3() {
-  if (i++ != 1)
-    __builtin_abort ();
-}
+extern int i;
 
 void d1() __attribute__((destructor (500)));
-void d2() __attribute__((destructor (700)));
-void d3() __attribute__((destructor (600)));
 
 void d1() {
   if (--i != 0)
     __builtin_abort ();
 }
-
-void d2() {
-  if (--i != 2)
-    __builtin_abort ();
-}
-
-void d3() {
-  if (j != 2)
-    __builtin_abort ();
-  if (--i != 1)
-    __builtin_abort ();
-}
-
-void cd4() __attribute__((constructor (800), destructor (800)));
-
-void cd4() {
-  if (i != 3)
-    __builtin_abort ();
-  ++j;
-}
-
-int main () {
-  if (i != 3)
-    return 1;
-  if (j != 1)
-    __builtin_abort ();
-  return 0;
-}
diff --git a/gcc/testsuite/c-c++-common/initpri1.c b/gcc/testsuite/c-c++-common/initpri1_part_d2.c
similarity index 20%
copy from gcc/testsuite/c-c++-common/initpri1.c
copy to gcc/testsuite/c-c++-common/initpri1_part_d2.c
index 387f2a39658..258cbbc495f 100644
--- a/gcc/testsuite/c-c++-common/initpri1.c
+++ b/gcc/testsuite/c-c++-common/initpri1_part_d2.c
@@ -1,61 +1,11 @@ 
-/* { dg-do run { target init_priority } } */
+/* { dg-skip-if part { *-*-* } } */
 /* Via the magic string "-std=*++" indicate that testing one (the default) C++ standard is sufficient.  */
 
-int i;
-int j;
+extern int i;
 
-void c1() __attribute__((constructor (500)));
-void c2() __attribute__((constructor (700)));
-void c3() __attribute__((constructor (600)));
-
-void c1() {
-  if (i++ != 0)
-    __builtin_abort ();
-}
-
-void c2() {
-  if (i++ != 2)
-    __builtin_abort ();
-}
-
-void c3() {
-  if (i++ != 1)
-    __builtin_abort ();
-}
-
-void d1() __attribute__((destructor (500)));
 void d2() __attribute__((destructor (700)));
-void d3() __attribute__((destructor (600)));
-
-void d1() {
-  if (--i != 0)
-    __builtin_abort ();
-}
 
 void d2() {
   if (--i != 2)
     __builtin_abort ();
 }
-
-void d3() {
-  if (j != 2)
-    __builtin_abort ();
-  if (--i != 1)
-    __builtin_abort ();
-}
-
-void cd4() __attribute__((constructor (800), destructor (800)));
-
-void cd4() {
-  if (i != 3)
-    __builtin_abort ();
-  ++j;
-}
-
-int main () {
-  if (i != 3)
-    return 1;
-  if (j != 1)
-    __builtin_abort ();
-  return 0;
-}
diff --git a/gcc/testsuite/c-c++-common/initpri1.c b/gcc/testsuite/c-c++-common/initpri1_part_d3.c
similarity index 23%
copy from gcc/testsuite/c-c++-common/initpri1.c
copy to gcc/testsuite/c-c++-common/initpri1_part_d3.c
index 387f2a39658..1242d411b07 100644
--- a/gcc/testsuite/c-c++-common/initpri1.c
+++ b/gcc/testsuite/c-c++-common/initpri1_part_d3.c
@@ -1,61 +1,14 @@ 
-/* { dg-do run { target init_priority } } */
+/* { dg-skip-if part { *-*-* } } */
 /* Via the magic string "-std=*++" indicate that testing one (the default) C++ standard is sufficient.  */
 
-int i;
-int j;
+extern int i;
+extern int j;
 
-void c1() __attribute__((constructor (500)));
-void c2() __attribute__((constructor (700)));
-void c3() __attribute__((constructor (600)));
-
-void c1() {
-  if (i++ != 0)
-    __builtin_abort ();
-}
-
-void c2() {
-  if (i++ != 2)
-    __builtin_abort ();
-}
-
-void c3() {
-  if (i++ != 1)
-    __builtin_abort ();
-}
-
-void d1() __attribute__((destructor (500)));
-void d2() __attribute__((destructor (700)));
 void d3() __attribute__((destructor (600)));
 
-void d1() {
-  if (--i != 0)
-    __builtin_abort ();
-}
-
-void d2() {
-  if (--i != 2)
-    __builtin_abort ();
-}
-
 void d3() {
   if (j != 2)
     __builtin_abort ();
   if (--i != 1)
     __builtin_abort ();
 }
-
-void cd4() __attribute__((constructor (800), destructor (800)));
-
-void cd4() {
-  if (i != 3)
-    __builtin_abort ();
-  ++j;
-}
-
-int main () {
-  if (i != 3)
-    return 1;
-  if (j != 1)
-    __builtin_abort ();
-  return 0;
-}
diff --git a/gcc/testsuite/c-c++-common/initpri1.c b/gcc/testsuite/c-c++-common/initpri1_part_main.c
similarity index 21%
copy from gcc/testsuite/c-c++-common/initpri1.c
copy to gcc/testsuite/c-c++-common/initpri1_part_main.c
index 387f2a39658..bff58d75e68 100644
--- a/gcc/testsuite/c-c++-common/initpri1.c
+++ b/gcc/testsuite/c-c++-common/initpri1_part_main.c
@@ -1,57 +1,9 @@ 
-/* { dg-do run { target init_priority } } */
+/* { dg-skip-if part { *-*-* } } */
 /* Via the magic string "-std=*++" indicate that testing one (the default) C++ standard is sufficient.  */
 
 int i;
 int j;
 
-void c1() __attribute__((constructor (500)));
-void c2() __attribute__((constructor (700)));
-void c3() __attribute__((constructor (600)));
-
-void c1() {
-  if (i++ != 0)
-    __builtin_abort ();
-}
-
-void c2() {
-  if (i++ != 2)
-    __builtin_abort ();
-}
-
-void c3() {
-  if (i++ != 1)
-    __builtin_abort ();
-}
-
-void d1() __attribute__((destructor (500)));
-void d2() __attribute__((destructor (700)));
-void d3() __attribute__((destructor (600)));
-
-void d1() {
-  if (--i != 0)
-    __builtin_abort ();
-}
-
-void d2() {
-  if (--i != 2)
-    __builtin_abort ();
-}
-
-void d3() {
-  if (j != 2)
-    __builtin_abort ();
-  if (--i != 1)
-    __builtin_abort ();
-}
-
-void cd4() __attribute__((constructor (800), destructor (800)));
-
-void cd4() {
-  if (i != 3)
-    __builtin_abort ();
-  ++j;
-}
-
 int main () {
   if (i != 3)
     return 1;