summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2016-02-16 12:52:05 -0800
committerH.J. Lu <hjl.tools@gmail.com>2016-02-17 12:48:04 -0800
commit1ed49e03e6ad9dc02dd460705125d7f579d05aeb (patch)
treed6605f90f7c0b8aaec8a532282b7c42606e15ed0
parent74875fc032adc4077cb319137c29b6e6a917f0e8 (diff)
downloadgcc-1ed49e03e6ad9dc02dd460705125d7f579d05aeb.tar.gz
Add more tests for empty types
-rw-r--r--gcc/testsuite/g++.dg/abi/empty16.C17
-rw-r--r--gcc/testsuite/g++.dg/abi/empty16.h16
-rw-r--r--gcc/testsuite/g++.dg/abi/empty16a.c6
-rw-r--r--gcc/testsuite/g++.dg/abi/empty17.C17
-rw-r--r--gcc/testsuite/g++.dg/abi/empty17.h27
-rw-r--r--gcc/testsuite/g++.dg/abi/empty17a.c6
-rw-r--r--gcc/testsuite/g++.dg/pr60336-10.C50
-rw-r--r--gcc/testsuite/g++.dg/pr60336-11.C56
-rw-r--r--gcc/testsuite/g++.dg/pr60336-12.C57
9 files changed, 252 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/abi/empty16.C b/gcc/testsuite/g++.dg/abi/empty16.C
new file mode 100644
index 00000000000..42705137475
--- /dev/null
+++ b/gcc/testsuite/g++.dg/abi/empty16.C
@@ -0,0 +1,17 @@
+// PR c++/60336
+// { dg-do run }
+// { dg-options "-x c" }
+// { dg-additional-sources "empty16a.c" }
+// { dg-prune-output "command line option" }
+
+#include "empty16.h"
+extern "C" void fun(struct dummy, struct foo);
+
+int main()
+{
+ struct dummy d;
+ struct foo f = { -1, -2, -3, -4, -5 };
+
+ fun(d, f); // { dg-message "note: the ABI of passing empty record has changed in GCC 6" }
+ return 0;
+}
diff --git a/gcc/testsuite/g++.dg/abi/empty16.h b/gcc/testsuite/g++.dg/abi/empty16.h
new file mode 100644
index 00000000000..7552ae06576
--- /dev/null
+++ b/gcc/testsuite/g++.dg/abi/empty16.h
@@ -0,0 +1,16 @@
+#ifdef __cplusplus
+struct A1 {};
+struct A2 {};
+struct dummy : A1, A2 {} ;
+#else
+struct dummy {};
+#endif
+
+struct foo
+{
+ int i1;
+ int i2;
+ int i3;
+ int i4;
+ int i5;
+};
diff --git a/gcc/testsuite/g++.dg/abi/empty16a.c b/gcc/testsuite/g++.dg/abi/empty16a.c
new file mode 100644
index 00000000000..6cb7fbccecc
--- /dev/null
+++ b/gcc/testsuite/g++.dg/abi/empty16a.c
@@ -0,0 +1,6 @@
+#include "empty16.h"
+void fun(struct dummy d, struct foo f)
+{
+ if (f.i1 != -1)
+ __builtin_abort();
+}
diff --git a/gcc/testsuite/g++.dg/abi/empty17.C b/gcc/testsuite/g++.dg/abi/empty17.C
new file mode 100644
index 00000000000..472708365ac
--- /dev/null
+++ b/gcc/testsuite/g++.dg/abi/empty17.C
@@ -0,0 +1,17 @@
+// PR c++/60336
+// { dg-do run }
+// { dg-options "-x c" }
+// { dg-additional-sources "empty17a.c" }
+// { dg-prune-output "command line option" }
+
+#include "empty17.h"
+extern "C" void fun(struct dummy, struct foo);
+
+int main()
+{
+ struct dummy d;
+ struct foo f = { -1, -2, -3, -4, -5 };
+
+ fun(d, f); // { dg-message "note: the ABI of passing empty record has changed in GCC 6" }
+ return 0;
+}
diff --git a/gcc/testsuite/g++.dg/abi/empty17.h b/gcc/testsuite/g++.dg/abi/empty17.h
new file mode 100644
index 00000000000..9cf72baca2e
--- /dev/null
+++ b/gcc/testsuite/g++.dg/abi/empty17.h
@@ -0,0 +1,27 @@
+#ifdef __cplusplus
+struct A1
+{
+ void foo (void);
+ unsigned int : 15;
+};
+struct A2
+{
+ void bar (void);
+ unsigned int : 15;
+};
+struct dummy : A1, A2
+{
+ unsigned int : 15;
+};
+#else
+struct dummy {};
+#endif
+
+struct foo
+{
+ int i1;
+ int i2;
+ int i3;
+ int i4;
+ int i5;
+};
diff --git a/gcc/testsuite/g++.dg/abi/empty17a.c b/gcc/testsuite/g++.dg/abi/empty17a.c
new file mode 100644
index 00000000000..24408fde09c
--- /dev/null
+++ b/gcc/testsuite/g++.dg/abi/empty17a.c
@@ -0,0 +1,6 @@
+#include "empty17.h"
+void fun(struct dummy d, struct foo f)
+{
+ if (f.i1 != -1)
+ __builtin_abort();
+}
diff --git a/gcc/testsuite/g++.dg/pr60336-10.C b/gcc/testsuite/g++.dg/pr60336-10.C
new file mode 100644
index 00000000000..6c9c990dad6
--- /dev/null
+++ b/gcc/testsuite/g++.dg/pr60336-10.C
@@ -0,0 +1,50 @@
+// { dg-do run }
+// { dg-options "-O2" }
+
+#include <stdarg.h>
+
+struct dummy0 { };
+struct dummy1 { };
+struct dummy : dummy0, dummy1 { };
+
+void
+test (struct dummy a, int m, ...)
+{
+ va_list va_arglist;
+ int i;
+ int count = 0;
+
+ if (m == 0)
+ count++;
+ va_start (va_arglist, m);
+ i = va_arg (va_arglist, int);
+ if (i == 1)
+ count++;
+ i = va_arg (va_arglist, int);
+ if (i == 2)
+ i = va_arg (va_arglist, int);
+ count++;
+ if (i == 3)
+ count++;
+ i = va_arg (va_arglist, int);
+ if (i == 4)
+ count++;
+ i = va_arg (va_arglist, int);
+ if (i == 5)
+ count++;
+ i = va_arg (va_arglist, int);
+ if (i == 6)
+ count++;
+ va_end (va_arglist);
+ if (count != 7)
+ __builtin_abort ();
+}
+
+struct dummy a0;
+
+int
+main ()
+{
+ test (a0, 0, 1, 2, 3, 4, 5, 6);
+ return 0;
+}
diff --git a/gcc/testsuite/g++.dg/pr60336-11.C b/gcc/testsuite/g++.dg/pr60336-11.C
new file mode 100644
index 00000000000..c92f3d43a5b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/pr60336-11.C
@@ -0,0 +1,56 @@
+// { dg-do run }
+// { dg-options "-O2" }
+
+#include <stdarg.h>
+
+struct dummy0
+{
+ void bar (void);
+};
+struct dummy1
+{
+ void foo (void);
+};
+struct dummy : dummy0, dummy1 { };
+
+void
+test (struct dummy a, int m, ...)
+{
+ va_list va_arglist;
+ int i;
+ int count = 0;
+
+ if (m == 0)
+ count++;
+ va_start (va_arglist, m);
+ i = va_arg (va_arglist, int);
+ if (i == 1)
+ count++;
+ i = va_arg (va_arglist, int);
+ if (i == 2)
+ i = va_arg (va_arglist, int);
+ count++;
+ if (i == 3)
+ count++;
+ i = va_arg (va_arglist, int);
+ if (i == 4)
+ count++;
+ i = va_arg (va_arglist, int);
+ if (i == 5)
+ count++;
+ i = va_arg (va_arglist, int);
+ if (i == 6)
+ count++;
+ va_end (va_arglist);
+ if (count != 7)
+ __builtin_abort ();
+}
+
+struct dummy a0;
+
+int
+main ()
+{
+ test (a0, 0, 1, 2, 3, 4, 5, 6);
+ return 0;
+}
diff --git a/gcc/testsuite/g++.dg/pr60336-12.C b/gcc/testsuite/g++.dg/pr60336-12.C
new file mode 100644
index 00000000000..83a7bb0cfa0
--- /dev/null
+++ b/gcc/testsuite/g++.dg/pr60336-12.C
@@ -0,0 +1,57 @@
+// { dg-do run }
+// { dg-options "-O2" }
+
+#include <stdarg.h>
+
+struct dummy0
+{
+};
+struct dummy1
+{
+ unsigned : 15;
+};
+struct dummy : dummy0, dummy1
+{
+};
+
+void
+test (struct dummy a, int m, ...)
+{
+ va_list va_arglist;
+ int i;
+ int count = 0;
+
+ if (m == 0)
+ count++;
+ va_start (va_arglist, m);
+ i = va_arg (va_arglist, int);
+ if (i == 1)
+ count++;
+ i = va_arg (va_arglist, int);
+ if (i == 2)
+ i = va_arg (va_arglist, int);
+ count++;
+ if (i == 3)
+ count++;
+ i = va_arg (va_arglist, int);
+ if (i == 4)
+ count++;
+ i = va_arg (va_arglist, int);
+ if (i == 5)
+ count++;
+ i = va_arg (va_arglist, int);
+ if (i == 6)
+ count++;
+ va_end (va_arglist);
+ if (count != 7)
+ __builtin_abort ();
+}
+
+struct dummy a0;
+
+int
+main ()
+{
+ test (a0, 0, 1, 2, 3, 4, 5, 6);
+ return 0;
+}