diff mbox series

[1/4] Consolidate similar C/C++ test cases for 'constructor', 'destructor' function attributes with priority

Message ID 20240604183051.1406924-2-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/
	* gcc.dg/initpri1.c: Integrate this...
	* g++.dg/special/initpri1.C: ..., and this...
	* c-c++-common/initpri1.c: ... here.
	* gcc.dg/initpri1-lto.c: Adjust.
	* gcc.dg/initpri2.c: Integrate this...
	* g++.dg/special/initpri2.C: ..., and this...
	* c-c++-common/initpri2.c: ... here.
---
 .../{gcc.dg => c-c++-common}/initpri1.c       | 21 +++----
 .../{gcc.dg => c-c++-common}/initpri2.c       |  1 +
 gcc/testsuite/g++.dg/special/initpri1.C       | 62 -------------------
 gcc/testsuite/g++.dg/special/initpri2.C       | 39 ------------
 gcc/testsuite/gcc.dg/initpri1-lto.c           |  2 +-
 5 files changed, 12 insertions(+), 113 deletions(-)
 rename gcc/testsuite/{gcc.dg => c-c++-common}/initpri1.c (68%)
 rename gcc/testsuite/{gcc.dg => c-c++-common}/initpri2.c (92%)
 delete mode 100644 gcc/testsuite/g++.dg/special/initpri1.C
 delete mode 100644 gcc/testsuite/g++.dg/special/initpri2.C
diff mbox series

Patch

diff --git a/gcc/testsuite/gcc.dg/initpri1.c b/gcc/testsuite/c-c++-common/initpri1.c
similarity index 68%
rename from gcc/testsuite/gcc.dg/initpri1.c
rename to gcc/testsuite/c-c++-common/initpri1.c
index b6afd7690de..387f2a39658 100644
--- a/gcc/testsuite/gcc.dg/initpri1.c
+++ b/gcc/testsuite/c-c++-common/initpri1.c
@@ -1,6 +1,5 @@ 
 /* { dg-do run { target init_priority } } */
-
-extern void abort (void);
+/* Via the magic string "-std=*++" indicate that testing one (the default) C++ standard is sufficient.  */
 
 int i;
 int j;
@@ -11,17 +10,17 @@  void c3() __attribute__((constructor (600)));
 
 void c1() {
   if (i++ != 0)
-    abort ();
+    __builtin_abort ();
 }
 
 void c2() {
   if (i++ != 2)
-    abort ();
+    __builtin_abort ();
 }
 
 void c3() {
   if (i++ != 1)
-    abort ();
+    __builtin_abort ();
 }
 
 void d1() __attribute__((destructor (500)));
@@ -30,26 +29,26 @@  void d3() __attribute__((destructor (600)));
 
 void d1() {
   if (--i != 0)
-    abort ();
+    __builtin_abort ();
 }
 
 void d2() {
   if (--i != 2)
-    abort ();
+    __builtin_abort ();
 }
 
 void d3() {
   if (j != 2)
-    abort ();
+    __builtin_abort ();
   if (--i != 1)
-    abort ();
+    __builtin_abort ();
 }
 
 void cd4() __attribute__((constructor (800), destructor (800)));
 
 void cd4() {
   if (i != 3)
-    abort ();
+    __builtin_abort ();
   ++j;
 }
 
@@ -57,6 +56,6 @@  int main () {
   if (i != 3)
     return 1;
   if (j != 1)
-    abort ();
+    __builtin_abort ();
   return 0;
 }
diff --git a/gcc/testsuite/gcc.dg/initpri2.c b/gcc/testsuite/c-c++-common/initpri2.c
similarity index 92%
rename from gcc/testsuite/gcc.dg/initpri2.c
rename to gcc/testsuite/c-c++-common/initpri2.c
index fa9fda0d7f3..bda2a626c64 100644
--- a/gcc/testsuite/gcc.dg/initpri2.c
+++ b/gcc/testsuite/c-c++-common/initpri2.c
@@ -1,4 +1,5 @@ 
 /* { dg-do compile { target init_priority } } */
+/* Via the magic string "-std=*++" indicate that testing one (the default) C++ standard is sufficient.  */
 
 /* Priorities must be in the range [0, 65535].  */
 void c1()
diff --git a/gcc/testsuite/g++.dg/special/initpri1.C b/gcc/testsuite/g++.dg/special/initpri1.C
deleted file mode 100644
index bd24961e46b..00000000000
--- a/gcc/testsuite/g++.dg/special/initpri1.C
+++ /dev/null
@@ -1,62 +0,0 @@ 
-/* { dg-do run { target init_priority } } */
-
-extern "C" void abort ();
-
-int i;
-int j;
-
-void c1() __attribute__((constructor (500)));
-void c2() __attribute__((constructor (700)));
-void c3() __attribute__((constructor (600)));
-
-void c1() {
-  if (i++ != 0)
-    abort ();
-}
-
-void c2() {
-  if (i++ != 2)
-    abort ();
-}
-
-void c3() {
-  if (i++ != 1)
-    abort ();
-}
-
-void d1() __attribute__((destructor (500)));
-void d2() __attribute__((destructor (700)));
-void d3() __attribute__((destructor (600)));
-
-void d1() {
-  if (--i != 0)
-    abort ();
-}
-
-void d2() {
-  if (--i != 2)
-    abort ();
-}
-
-void d3() {
-  if (j != 2)
-    abort ();
-  if (--i != 1)
-    abort ();
-}
-
-void cd4() __attribute__((constructor (800), destructor (800)));
-
-void cd4() {
-  if (i != 3)
-    abort ();
-  ++j;
-}
-
-int main () {
-  if (i != 3)
-    return 1;
-  if (j != 1)
-    abort ();
-  return 0;
-}
diff --git a/gcc/testsuite/g++.dg/special/initpri2.C b/gcc/testsuite/g++.dg/special/initpri2.C
deleted file mode 100644
index fa9fda0d7f3..00000000000
--- a/gcc/testsuite/g++.dg/special/initpri2.C
+++ /dev/null
@@ -1,39 +0,0 @@ 
-/* { dg-do compile { target init_priority } } */
-
-/* Priorities must be in the range [0, 65535].  */
-void c1()
-     __attribute__((constructor (-1))); /* { dg-error "priorities" } */
-void c2() 
-     __attribute__((constructor (65536))); /* { dg-error "priorities" } */
-void d1() 
-     __attribute__((destructor (-1))); /* { dg-error "priorities" } */
-void d2() 
-     __attribute__((destructor (65536))); /* { dg-error "priorities" } */
-
-/* Priorities 0-100 are reserved for system libraries.  */
-void c3() 
-     __attribute__((constructor (50))); /* { dg-warning "reserved" } */
-void d3() 
-     __attribute__((constructor (50))); /* { dg-warning "reserved" } */
-
-/* Priorities must be integral constants.  */
-
-/* Pointers, even with constant values, are not allowed.  */
-void c4() 
-     __attribute__((constructor ((void*) 500))); /* { dg-error "priorities" } */
-void d4()    
-     __attribute__((destructor ((void*) 500))); /* { dg-error "priorities" } */
-
-/* Integer variables are not allowed.  */
-int i;
-void c5() 
-     __attribute__((constructor ((i)))); /* { dg-error "priorities" } */
-void d5()    
-     __attribute__((destructor ((i)))); /* { dg-error "priorities" } */
-
-/* Enumeration constants are allowed.  */
-enum E { e = 500 };
-void c6() 
-     __attribute__((constructor ((e))));
-void d6()    
-     __attribute__((destructor ((e))));
diff --git a/gcc/testsuite/gcc.dg/initpri1-lto.c b/gcc/testsuite/gcc.dg/initpri1-lto.c
index 98a43c3ff0d..0c97cf4b1c9 100644
--- a/gcc/testsuite/gcc.dg/initpri1-lto.c
+++ b/gcc/testsuite/gcc.dg/initpri1-lto.c
@@ -2,4 +2,4 @@ 
 /* { dg-require-effective-target lto } */
 /* { dg-options "-flto -O3" } */
 
-#include "initpri1.c"
+#include "../c-c++-common/initpri1.c"