scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | Submodules | README | LICENSE

0215-ret_struct.c (304B)


      1 struct f {
      2 	char fill[40];
      3 	int a;
      4 };
      5 
      6 struct f
      7 f1(struct f a)
      8 {
      9 	a.a += 2;
     10 	return a;
     11 }
     12 
     13 struct f
     14 f2(struct f a)
     15 {
     16 	struct f b;
     17 
     18 	b.a = a.a + 2;
     19 	return b;
     20 }
     21 
     22 int
     23 main()
     24 {
     25 	struct f a, b;
     26 
     27 	a.a = 1;
     28 	b = f1(a);
     29 	if (b.a != a.a + 2)
     30 		return 1;
     31 	b = f2(a);
     32 	if (b.a != a.a + 2)
     33 		return 2;
     34 
     35 	return 0;
     36 }