summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.c-torture/execute/struct-ret-1.c
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/gcc.c-torture/execute/struct-ret-1.c
downloadcbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2
cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository.
Diffstat (limited to 'gcc/testsuite/gcc.c-torture/execute/struct-ret-1.c')
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/struct-ret-1.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.c-torture/execute/struct-ret-1.c b/gcc/testsuite/gcc.c-torture/execute/struct-ret-1.c
new file mode 100644
index 000000000..e5274ec4c
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/struct-ret-1.c
@@ -0,0 +1,57 @@
+#include <stdio.h>
+#include <string.h>
+
+char out[100];
+
+typedef struct { double d; int i[3]; } B;
+typedef struct { char c[33],c1; } X;
+
+char c1 = 'a';
+char c2 = 127;
+char c3 = (char)128;
+char c4 = (char)255;
+char c5 = -1;
+
+double d1 = 0.1;
+double d2 = 0.2;
+double d3 = 0.3;
+double d4 = 0.4;
+double d5 = 0.5;
+double d6 = 0.6;
+double d7 = 0.7;
+double d8 = 0.8;
+double d9 = 0.9;
+
+B B1 = {0.1,{1,2,3}};
+B B2 = {0.2,{5,4,3}};
+X X1 = {"abcdefghijklmnopqrstuvwxyzABCDEF", 'G'};
+X X2 = {"123",'9'};
+X X3 = {"return-return-return",'R'};
+
+X f (B a, char b, double c, B d)
+{
+ static X xr = {"return val", 'R'};
+ X r;
+ r = xr;
+ r.c1 = b;
+ sprintf (out, "X f(B,char,double,B):({%g,{%d,%d,%d}},'%c',%g,{%g,{%d,%d,%d}})",
+ a.d, a.i[0], a.i[1], a.i[2], b, c, d.d, d.i[0], d.i[1], d.i[2]);
+ return r;
+}
+
+X (*fp) (B, char, double, B) = &f;
+
+main ()
+{
+ X Xr;
+ char tmp[100];
+
+ Xr = f (B1, c2, d3, B2);
+ strcpy (tmp, out);
+ Xr.c[0] = Xr.c1 = '\0';
+ Xr = (*fp) (B1, c2, d3, B2);
+ if (strcmp (tmp, out))
+ abort ();
+
+ exit (0);
+}