scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit 4ae875181944ff1af246660aa69e13053aef7ec6
parent c11910371793063297b672c0ed228e9599a7401e
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Tue,  9 Aug 2016 17:08:15 +0200

[cc1] Add test065

This test tests really strange situations about pointers, decay,
and the content operator. If you someday in your life see a code
like this in production you should kill to the author.

Diffstat:
Acc1/tests/test065.c | 66++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 66 insertions(+), 0 deletions(-)

diff --git a/cc1/tests/test065.c b/cc1/tests/test065.c @@ -0,0 +1,66 @@ +/* See LICENSE file for copyright and license details. */ + +/* +name: TEST065 +description: Test decay mixed with * operators +error: +test065.c:65: error: decrement of pointer to an incomplete type +test065.c:65: error: invalid use of undefined type +test065.c:66: warning: 'argv' defined but not used +output: +G7 I F "main +{ +A1 I "argc +A5 P "argv +\ +V8 I #N1 +A9 V8 "v +A12 P "p +A14 P "f1 +A15 P "f2 + A9 #I0 :I + A12 A9 'P :P + A14 G7 'P :P + A15 G7 'P :P + y L18 A1 #I0 !I + h #I1 +L18 + y L19 G7 #I0 pI #P0 pP cI #I0 =I + h #I2 +L19 + y L20 A14 @F #I0 pI #P0 pP cI #I0 =I + h #I3 +L20 + y L21 A15 @F #I0 pI #P0 pP cI #I0 =I + h #I4 +L21 + y L22 A12 @I #I0 !I + h #I0 +L22 +*/ + +int +main(int argc, char *argv[]) +{ + int v[1]; + int (*p)[]; + int (*f1)(int ,char *[]); + int (*f2)(int ,char *[]); + + v[0] = 0; + p = &v; + f1 = &main; + f2 = main; + if (argc == 0) + return 1; + if ((****main)(0, 0)) + return 2; + if ((****f1)(0, 0)) + return 3; + if ((****f2)(0, 0)) + return 4; + if (!(*p)[0]) + return 0; + + return (*++p)[0] || p[1][0]; +}