scc

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

commit b4f1a5ae6dce5d9b5bd6b1bfb99706d96d5f51ac
parent 4187be1a9dd2ee23522cd0dcd78deb046f8c3170
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Fri, 11 Aug 2017 09:27:48 +0100

[tests] Move cc1/tests to tests/

All the tests in cc1/tests are from a legacy test suite that is not
used anymore. This test tested cc1 IR, and it was very good to test
internal aspects of cc1, but for this reason it was very difficult
to maintain it accurate, because any small change in cc1 generated
a fail in the tests. Tests/ is a more convenient test framework
since it may be used for any architecture and not only for z80.

Diffstat:
Dcc1/tests/chktest.sh | 26--------------------------
Dcc1/tests/stdio.h | 6------
Dcc1/tests/test001.c | 30------------------------------
Dcc1/tests/test002.c | 49-------------------------------------------------
Dcc1/tests/test003.c | 41-----------------------------------------
Dcc1/tests/test004.c | 57---------------------------------------------------------
Dcc1/tests/test005.c | 38--------------------------------------
Dcc1/tests/test006.c | 61-------------------------------------------------------------
Dcc1/tests/test007.c | 34----------------------------------
Dcc1/tests/test008.c | 45---------------------------------------------
Dcc1/tests/test009.c | 39---------------------------------------
Dcc1/tests/test010.c | 97-------------------------------------------------------------------------------
Dcc1/tests/test011.c | 38--------------------------------------
Dcc1/tests/test012.c | 102-------------------------------------------------------------------------------
Dcc1/tests/test013.c | 273-------------------------------------------------------------------------------
Dcc1/tests/test014.c | 87-------------------------------------------------------------------------------
Dcc1/tests/test015.c | 56--------------------------------------------------------
Dcc1/tests/test016.c | 95-------------------------------------------------------------------------------
Dcc1/tests/test017.c | 54------------------------------------------------------
Dcc1/tests/test018.c | 61-------------------------------------------------------------
Dcc1/tests/test019.c | 62--------------------------------------------------------------
Dcc1/tests/test020.c | 84-------------------------------------------------------------------------------
Dcc1/tests/test021.c | 44--------------------------------------------
Dcc1/tests/test022.c | 58----------------------------------------------------------
Dcc1/tests/test023.c | 58----------------------------------------------------------
Dcc1/tests/test024.c | 54------------------------------------------------------
Dcc1/tests/test025.c | 66------------------------------------------------------------------
Dcc1/tests/test026.c | 43-------------------------------------------
Dcc1/tests/test027.c | 31-------------------------------
Dcc1/tests/test028.c | 28----------------------------
Dcc1/tests/test029.c | 39---------------------------------------
Dcc1/tests/test030.c | 60------------------------------------------------------------
Dcc1/tests/test031.c | 26--------------------------
Dcc1/tests/test032.c | 31-------------------------------
Dcc1/tests/test033.c | 20--------------------
Dcc1/tests/test034.c | 48------------------------------------------------
Dcc1/tests/test035.c | 51---------------------------------------------------
Dcc1/tests/test036.c | 75---------------------------------------------------------------------------
Dcc1/tests/test037.c | 37-------------------------------------
Dcc1/tests/test038.c | 45---------------------------------------------
Dcc1/tests/test039.c | 59-----------------------------------------------------------
Dcc1/tests/test040.c | 34----------------------------------
Dcc1/tests/test041.c | 54------------------------------------------------------
Dcc1/tests/test042.c | 21---------------------
Dcc1/tests/test043.c | 35-----------------------------------
Dcc1/tests/test044.c | 34----------------------------------
Dcc1/tests/test045.c | 31-------------------------------
Dcc1/tests/test046.c | 42------------------------------------------
Dcc1/tests/test047.c | 53-----------------------------------------------------
Dcc1/tests/test048.c | 44--------------------------------------------
Dcc1/tests/test049.c | 33---------------------------------
Dcc1/tests/test050.c | 22----------------------
Dcc1/tests/test051.c | 42------------------------------------------
Dcc1/tests/test052.c | 52----------------------------------------------------
Dcc1/tests/test053.c | 39---------------------------------------
Dcc1/tests/test054.c | 24------------------------
Dcc1/tests/test055.c | 45---------------------------------------------
Dcc1/tests/test056.c | 50--------------------------------------------------
Dcc1/tests/test057.c | 46----------------------------------------------
Dcc1/tests/test058.c | 65-----------------------------------------------------------------
Dcc1/tests/test059.c | 17-----------------
Dcc1/tests/test060.c | 28----------------------------
Dcc1/tests/test061.c | 24------------------------
Dcc1/tests/test062.c | 24------------------------
Dcc1/tests/test063.c | 12------------
Dcc1/tests/test063.h | 9---------
Dcc1/tests/test064.c | 32--------------------------------
Dcc1/tests/test065.c | 66------------------------------------------------------------------
Dcc1/tests/test066.c | 55-------------------------------------------------------
Dcc1/tests/update.sh | 26--------------------------
Atests/error/0020-storage.c | 37+++++++++++++++++++++++++++++++++++++
Atests/error/0021-namespace.c | 29+++++++++++++++++++++++++++++
Atests/error/0021-void.c | 7+++++++
Atests/error/0022-cpp-if.c | 9+++++++++
Atests/error/0023-include.c | 7+++++++
Atests/error/0023-include.h | 8++++++++
Mtests/error/scc-tests.lst | 4++++
Mtests/execute/0039-sizeof.c | 13++++++++++---
Atests/execute/0131-hello.c | 8++++++++
Atests/execute/0132-forward.c | 21+++++++++++++++++++++
Atests/execute/0133-ftn-ptr.c | 17+++++++++++++++++
Atests/execute/0134-arith.c | 37+++++++++++++++++++++++++++++++++++++
Atests/execute/0135-unary.c | 14++++++++++++++
Atests/execute/0136-if.c | 21+++++++++++++++++++++
Atests/execute/0137-int-cast.c | 275+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Atests/execute/0138-namespace.c | 30++++++++++++++++++++++++++++++
Atests/execute/0139-ptr-ary.c | 22++++++++++++++++++++++
Atests/execute/0140-int-fold.c | 27+++++++++++++++++++++++++++
Atests/execute/0141-int-iden.c | 37+++++++++++++++++++++++++++++++++++++
Atests/execute/0142-char-const.c | 41+++++++++++++++++++++++++++++++++++++++++
Atests/execute/0143-int-const.c | 24++++++++++++++++++++++++
Atests/execute/0144-long-const.c | 25+++++++++++++++++++++++++
Atests/execute/0145-llong-const.c | 23+++++++++++++++++++++++
Atests/execute/0146-ifdef.c | 52++++++++++++++++++++++++++++++++++++++++++++++++++++
Atests/execute/0147-intern-cpp.c | 19+++++++++++++++++++
Atests/execute/0148-cpp-string.c | 10++++++++++
Atests/execute/0149-define.c | 10++++++++++
Atests/execute/0150-define.c | 15+++++++++++++++
Atests/execute/0151-vararg.c | 25+++++++++++++++++++++++++
Atests/execute/0152-cat.c | 14++++++++++++++
Atests/execute/0153-cpp-string.c | 13+++++++++++++
Atests/execute/0154-if-defined | 15+++++++++++++++
Atests/execute/0155-struct-compl.c | 16++++++++++++++++
Atests/execute/0156-duff2.c | 35+++++++++++++++++++++++++++++++++++
Atests/execute/0157-list.c | 14++++++++++++++
Atests/execute/0158-ternary.c | 17+++++++++++++++++
Atests/execute/0159-typedef.c | 24++++++++++++++++++++++++
Atests/execute/0160-cpp-if.c | 17+++++++++++++++++
Atests/execute/0161-struct.c | 12++++++++++++
Atests/execute/0162-array.c | 13+++++++++++++
Atests/execute/0163-array.c | 16++++++++++++++++
Atests/execute/0164-struct.c | 12++++++++++++
Atests/execute/0165-struct.c | 33+++++++++++++++++++++++++++++++++
Atests/execute/0166-desig.c | 18++++++++++++++++++
Atests/execute/0167-array.c | 15+++++++++++++++
Atests/execute/0168-array.c | 16++++++++++++++++
Atests/execute/0169-string.c | 27+++++++++++++++++++++++++++
Atests/execute/0170-line.c | 13+++++++++++++
Atests/execute/0171-macros.c | 10++++++++++
Atests/execute/0172-hexa.c | 10++++++++++
Atests/execute/0173-macro.c | 13+++++++++++++
Atests/execute/0174-decay.c | 24++++++++++++++++++++++++
Atests/execute/0175-defined.c | 32++++++++++++++++++++++++++++++++
Mtests/execute/scc-tests.lst | 45+++++++++++++++++++++++++++++++++++++++++++++
124 files changed, 1338 insertions(+), 3370 deletions(-)

diff --git a/cc1/tests/chktest.sh b/cc1/tests/chktest.sh @@ -1,26 +0,0 @@ -#!/bin/sh -# See LICENSE file for copyright and license details. - -out=/tmp/$$.out -err=/tmp/$$.err -chk=/tmp/$$.chk -tst=/tmp/$$.tst - -trap "rm -f $out $chk $err $tst" EXIT INT QUIT HUP -rm -f test.log - -for i -do - rm -f $chk - awk '/^name:/ {printf "Running %s ", $2} - /^error:$/ {copyon=1; next} - /^TODO/ {printf "[DISABLED]"} - /^output:$/ {next} - /^\*\// {copyon=0; next} - copyon==1 {print > "'$chk'"}' $i - - ../cc1-z80 -I. -w $i > $out 2>$err - echo $i >> test.log - cat $err $out > $tst - diff -c $chk $tst >> test.log && echo [OK] || echo [FAILED] -done diff --git a/cc1/tests/stdio.h b/cc1/tests/stdio.h @@ -1,6 +0,0 @@ -#ifndef _STDIO_H -#define _STDIO_H - -int printf(const char *fmt, ...); - -#endif diff --git a/cc1/tests/test001.c b/cc1/tests/test001.c @@ -1,30 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* -name: TEST001 -description: Basic hello world test -error: -output: -X4 I F "printf -G6 I F "main -{ -\ -V8 K #ND -Y9 V8 " ( - #"hello world - #K0A - #K00 -) - X4 Y9 'P pP cI - h #I0 -} -*/ - -#include <stdio.h> - -int -main(void) -{ - printf("hello world\n"); - return 0; -} diff --git a/cc1/tests/test002.c b/cc1/tests/test002.c @@ -1,49 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* -name: TEST002 -description: Test forward references before definition of types -error: -output: -G4 P "x -S2 "S #N8 #N2 -M5 I "i #N0 -M6 P "next #N2 -G8 I F "main -{ -\ -A9 S2 "y -A10 P "p -A11 N "n - A9 M5 .I #I0 :I - G4 @S2 A9 :S2 - A11 #N0 :N A10 A9 'P :P ,P - j L14 - e -L12 - A11 #N1 :+N A10 A10 @S2 M6 .P :P ,P -L14 - y L12 A10 #P0 !I - b -L13 -} -*/ - -struct S *x; -struct S { - int i; - struct S *next; -}; - -int -main(void) -{ - struct S y, *p; - unsigned n; - - y.i = 0; - *x = y; - - for (n = 0, p = &y; p; ++n, p = p->next) - /* nothing */; -} diff --git a/cc1/tests/test003.c b/cc1/tests/test003.c @@ -1,41 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* -name: TEST003 -description: Select function to call inside ternary operator -error: -output: -G2 I F "foo -{ -\ - h #I2A -} -G3 I F "bar -{ -\ - h #I18 -} -G4 I F "main -{ -\ - h G2 cI -} -*/ - -int -foo(void) -{ - return 42; -} - -int -bar(void) -{ - return 24; -} - -int -main(void) -{ - return (1 ? foo : bar)(); -} diff --git a/cc1/tests/test004.c b/cc1/tests/test004.c @@ -1,57 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* -name: TEST004 -description: Test integer operations -error: -output: -G2 I F "main -{ -\ -A3 I "x - A3 #I0 :I - A3 A3 #I2 +I :I - A3 A3 #I1 -I :I - A3 A3 #I6 *I :I - A3 A3 #I2 /I :I - A3 A3 #I2 %I :I - A3 A3 #I2 lI :I - A3 A3 #I1 rI :I - A3 A3 #IFF |I :I - A3 A3 #I3 &I :I - A3 A3 #I1 ^I :I - A3 A3 A3 #I1 >I +I :I - A3 A3 A3 #I3 <I +I :I - A3 A3 A3 #I1 >I +I :I - A3 A3 A3 #I4 <I +I :I - y L4 A3 #I4 =I - h #I1 -L4 - h #I0 -} -*/ - -int -main() -{ - int x; - - x = 0; - x = x + 2; // 2 - x = x - 1; // 1 - x = x * 6; // 6 - x = x / 2; // 3 - x = x % 2; // 1 - x = x << 2; // 4 - x = x >> 1; // 2 - x = x | 255; // 255 - x = x & 3; // 3 - x = x ^ 1; // 2 - x = x + (x > 1); // 2 - x = x + (x < 3); // 2 - x = x + (x > 1); // 3 - x = x + (x < 4); // 4 - if(x != 4) - return 1; - return 0; -} diff --git a/cc1/tests/test005.c b/cc1/tests/test005.c @@ -1,38 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* -name: TEST005 -description: Test unary integer operations -error: -output: -G2 I F "main -{ -\ -A3 I "x - A3 #I3 :I - A3 A3 #I0 =I :I - A3 A3 #I0 =I :I - A3 A3 ~I :I - A3 A3 _I :I - y L4 A3 #I2 =I - h #I1 -L4 - h #I0 -} -*/ - - -int -main() -{ - int x; - - x = 3; - x = !x; // 0 - x = !x; // 1 - x = ~x; // -1 - x = -x; // 2 - if(x != 2) - return 1; - return 0; -} diff --git a/cc1/tests/test006.c b/cc1/tests/test006.c @@ -1,61 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* -name: TEST006 -description: Basic test for if -error: -test006.c:5: warning: conditional expression is constant -test006.c:7: warning: conditional expression is constant -test006.c:10: warning: conditional expression is constant -output: -G1 K "c -G3 I F "main -{ -\ - y L4 #I1 - h #I1 - j L5 -L4 - y L6 #I1 - j L7 -L6 - y L8 #I0 - y L9 G1 gI #I0 =I - h #I1 - j L10 -L9 - h #I0 -L10 - j L11 -L8 - h #I1 -L11 -L7 -L5 - h #I1 -} -*/ - -char c; - -#line 1 - -int -main() -{ - if(0) { - return 1; - } else if(0) { - /* empty */ - } else { - if(1) { - if(c) - return 1; - else - return 0; - } else { - return 1; - } - } - return 1; -} diff --git a/cc1/tests/test007.c b/cc1/tests/test007.c @@ -1,34 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* -name: TEST007 -description: basic while test -error: -output: -G2 I F "main -{ -\ -A3 I "x - A3 #IA :I - j L6 - e -L4 - A3 A3 #I1 -I :I -L6 - y L4 A3 #I0 !I - b -L5 - h A3 -} -*/ - -int -main() -{ - int x; - - x = 10; - while (x) - x = x - 1; - return x; -} diff --git a/cc1/tests/test008.c b/cc1/tests/test008.c @@ -1,45 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* -name: TEST008 -description: Basic do while loop -error: -output: -G2 I F "main -{ -\ -A3 I "x - A3 #I0 :I - e -L4 - A3 A3 #I1 +I :I - y L4 A3 #IA <I - b -L5 - e -L6 - A3 A3 #I1 +I :I - y L6 A3 #I14 <I - b -L7 - h A3 #I14 -I -} -*/ - -int -main() -{ - int x; - - x = 0; - do - x = x + 1; - while (x < 10); - - do { - x = x + 1; - } while (x < 20); - - return x - 20; -} - diff --git a/cc1/tests/test009.c b/cc1/tests/test009.c @@ -1,39 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* -name: TEST009 -description: Basic test for loops -error: -output: -G2 I F "main -{ -\ -A3 I "x - A3 #I0 :I - j L6 - e -L4 - A3 A3 #I1 +I :I -L6 - y L4 A3 #IA <I - b -L5 - y L7 A3 #IA =I - h #I1 -L7 - h #I0 -} -*/ - -int -main() -{ - int x; - - for (x = 0; x < 10 ; x = x + 1) - ; - if (x != 10) - return 1; - return 0; -} - diff --git a/cc1/tests/test010.c b/cc1/tests/test010.c @@ -1,97 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* -name: TEST010 -description: Test for continue and break statements -error: -test010.c:8: warning: conditional expression is constant -test010.c:10: warning: conditional expression is constant -test010.c:30: warning: conditional expression is constant -output: -G2 I F "main -{ -\ -A3 I "x - A3 #I0 :I - j L6 - e -L4 - j L5 -L6 - y L4 #I1 - b -L5 - j L9 - e -L7 - y L10 A3 #I5 !I - j L8 -L10 - A3 A3 #I1 +I :I - j L7 -L9 - y L7 #I1 - b -L8 - - j L13 - e -L11 - y L14 A3 #IA !I - j L12 -L14 - A3 A3 #I1 +I :I - j L11 - -L13 - j L11 - - b -L12 - e -L15 - y L17 A3 #IF !I - j L16 -L17 - A3 A3 #I1 +I :I - j L15 - y L15 #I1 - b -L16 - h A3 #IF -I -} -*/ - -#line 1 - -int -main() -{ - int x; - - x = 0; - while(1) - break; - while(1) { - if (x == 5) { - break; - } - x = x + 1; - continue; - } - for (;;) { - if (x == 10) { - break; - } - x = x + 1; - continue; - } - do { - if (x == 15) { - break; - } - x = x + 1; - continue; - } while(1); - return x - 15; -} diff --git a/cc1/tests/test011.c b/cc1/tests/test011.c @@ -1,38 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* -name: TEST011 -description: Basic test for goto -error: -test011.c:13: warning: 'foo' defined but not used -test011.c:13: warning: 'start' defined but not used -output: -G2 I F "main -{ -\ -L3 - j L4 - h #I1 -L5 - h #I0 -L4 -L6 - j L5 - h #I1 -} -*/ - -#line 1 - -int -main() { - start: - goto next; - return 1; - success: - return 0; - next: - foo: - goto success; - return 1; -} diff --git a/cc1/tests/test012.c b/cc1/tests/test012.c @@ -1,102 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* -name: TEST012 -description: Basic switch test -error: -test012.c:38: warning: 'foo' defined but not used -output: -G2 I F "main -{ -\ -A3 I "x - A3 #I0 :I - s A3 - v L5 #I0 -L5 - t L4 -L4 - s A3 - v L7 #I0 -L7 - s A3 - v L9 #I0 -L9 - j L10 - f L11 -L11 - h #I1 - t L8 -L8 - t L6 -L6 - h #I2 -L10 - s A3 - v L13 #I1 -L13 - h #I3 - t L12 -L12 - s A3 - A3 #I2 :I -L15 - v L16 #I1 -L16 - h #I4 - t L14 -L14 - s A3 - v L18 #I0 -L18 - h A3 - v L19 #I1 -L19 - h #I1 - f L20 -L20 - h #I1 - t L17 -L17 -} -*/ - -#line 1 - -int -main() -{ - int x; - - x = 0; - switch(x) - case 0: - ; - switch(x) - case 0: - switch(x) { - case 0: - goto next; - default: - return 1; - } - return 2; - next: - switch(x) - case 1: - return 3; - switch(x) { - x = 1 + 1; - foo: - case 1: - return 4; - } - switch(x) { - case 0: - return x; - case 1: - return 1; - default: - return 1; - } -} diff --git a/cc1/tests/test013.c b/cc1/tests/test013.c @@ -1,273 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* -name: TEST013 -description: Basic test of integer types and integer conversions -comments: This test depends of the configuration in the type system. - With the current configuration char is equal to unsigned char, - short is equal to int, and unsigned short is equal to unsigned. -error: -output: -G1 I "a -G2 N "b -G3 K "c -G4 C "d -G5 K "e -G6 W "f -G7 Z "g -G8 Q "h -G9 O "i -G10 I "j -G11 N "k -G13 I F "main -{ -\ - G1 G2 gI :I - G1 G3 gI :I - G1 G4 gI :I - G1 G5 gI :I - G1 G6 gI :I - G1 G7 gI :I - G1 G8 gI :I - G1 G9 gI :I - G1 G10 :I - G1 G11 gI :I - G2 G1 gN :N - G2 G3 gN :N - G2 G4 gN :N - G2 G5 gN :N - G2 G6 gN :N - G2 G7 gN :N - G2 G8 gN :N - G2 G9 gN :N - G2 G10 gN :N - G2 G11 :N - G3 G1 gK :K - G3 G2 gK :K - G3 G4 gK :K - G3 G5 :K - G3 G6 gK :K - G3 G7 gK :K - G3 G8 gK :K - G3 G9 gK :K - G3 G10 gK :K - G3 G11 gK :K - G4 G1 gC :C - G4 G2 gC :C - G4 G3 gC :C - G4 G5 gC :C - G4 G6 gC :C - G4 G7 gC :C - G4 G8 gC :C - G4 G9 gC :C - G4 G10 gC :C - G4 G11 gC :C - G5 G1 gK :K - G5 G2 gK :K - G5 G3 :K - G5 G4 gK :K - G5 G6 gK :K - G5 G7 gK :K - G5 G8 gK :K - G5 G9 gK :K - G5 G10 gK :K - G5 G11 gK :K - G6 G1 gW :W - G6 G2 gW :W - G6 G3 gW :W - G6 G4 gW :W - G6 G5 gW :W - G6 G7 gW :W - G6 G8 gW :W - G6 G9 gW :W - G6 G10 gW :W - G6 G11 gW :W - G7 G1 gZ :Z - G7 G2 gZ :Z - G7 G3 gZ :Z - G7 G4 gZ :Z - G7 G5 gZ :Z - G7 G6 gZ :Z - G7 G8 gZ :Z - G7 G9 gZ :Z - G7 G10 gZ :Z - G7 G11 gZ :Z - G8 G1 gQ :Q - G8 G2 gQ :Q - G8 G3 gQ :Q - G8 G4 gQ :Q - G8 G5 gQ :Q - G8 G6 gQ :Q - G8 G7 gQ :Q - G8 G9 gQ :Q - G8 G10 gQ :Q - G8 G11 gQ :Q - G9 G1 gO :O - G9 G2 gO :O - G9 G3 gO :O - G9 G4 gO :O - G9 G5 gO :O - G9 G6 gO :O - G9 G7 gO :O - G9 G8 gO :O - G9 G10 gO :O - G9 G11 gO :O - G10 G1 :I - G10 G2 gI :I - G10 G3 gI :I - G10 G4 gI :I - G10 G5 gI :I - G10 G6 gI :I - G10 G7 gI :I - G10 G8 gI :I - G10 G9 gI :I - G10 G11 gI :I - G11 G1 gN :N - G11 G2 :N - G11 G3 gN :N - G11 G4 gN :N - G11 G5 gN :N - G11 G6 gN :N - G11 G7 gN :N - G11 G8 gN :N - G11 G10 gN :N - G11 G9 gN :N -} -*/ - -int a; -unsigned b; -char c; -signed char d; -unsigned char e; -long f; -unsigned long g; -long long h; -unsigned long long i; -short j; -unsigned short k; - -int -main(void) -{ - a = b; - a = c; - a = d; - a = e; - a = f; - a = g; - a = h; - a = i; - a = j; - a = k; - - b = a; - b = c; - b = d; - b = e; - b = f; - b = g; - b = h; - b = i; - b = j; - b = k; - - c = a; - c = b; - c = d; - c = e; - c = f; - c = g; - c = h; - c = i; - c = j; - c = k; - - d = a; - d = b; - d = c; - d = e; - d = f; - d = g; - d = h; - d = i; - d = j; - d = k; - - e = a; - e = b; - e = c; - e = d; - e = f; - e = g; - e = h; - e = i; - e = j; - e = k; - - f = a; - f = b; - f = c; - f = d; - f = e; - f = g; - f = h; - f = i; - f = j; - f = k; - - g = a; - g = b; - g = c; - g = d; - g = e; - g = f; - g = h; - g = i; - g = j; - g = k; - - h = a; - h = b; - h = c; - h = d; - h = e; - h = f; - h = g; - h = i; - h = j; - h = k; - - i = a; - i = b; - i = c; - i = d; - i = e; - i = f; - i = g; - i = h; - i = j; - i = k; - - j = a; - j = b; - j = c; - j = d; - j = e; - j = f; - j = g; - j = h; - j = i; - j = k; - - k = a; - k = b; - k = c; - k = d; - k = e; - k = f; - k = g; - k = h; - k = j; - k = i; -} diff --git a/cc1/tests/test014.c b/cc1/tests/test014.c @@ -1,87 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* -name: TEST014 -description: Basic storage class test -error: -test014.c:15: warning: 'a' defined but not used -test014.c:15: warning: 'k' defined but not used -test014.c:15: warning: 'j' defined but not used -test014.c:15: warning: 'i' defined but not used -test014.c:15: warning: 'h' defined but not used -test014.c:21: warning: 'par' defined but not used -test014.c:21: warning: 'par' defined but not used -test014.c:26: warning: 'par' defined but not used -test014.c:28: error: incorrect storage class for file-scope declaration -test014.c:31: error: bad storage class in function parameter -test014.c:32: error: invalid storage class for function 'func4' -test014.c:33: error: invalid type specification -test014.c:34: warning: 'f' defined but not used -test014.c:34: warning: 'par' defined but not used -test014.c:37: error: conflicting types for 'd' -output: -G1 I "a -Y2 K "b -X3 I "c -G6 I F "func1 -{ -\ -A7 I "h -T8 K "i -R9 W "j -X10 I "k -T11 Z "a - h #I0 -} -G14 0 F "func2 -{ -R12 I "par -\ -A15 I "par -} -T17 0 F "func3 -{ -R16 I "par -\ -} -*/ - -#line 1 -int a; -static char b; -extern int c; -typedef unsigned e; - -int -func1(void) -{ - auto h; - static char i; - register long j; - extern int k; - static unsigned long a; - return 0; -} - -void -func2(register int par) -{ - int par; -} - -static void -func3(register int par) -{ -} - -register short d; - -register void -func4(static int par) -{ - static register f; -} - -short d; -char d; - diff --git a/cc1/tests/test015.c b/cc1/tests/test015.c @@ -1,56 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* -name: TEST015 -description: Stress namespace mechanism -error: -test015.c:54: error: label 's' already defined -output: -S8 "s2 #N2 #N1 -M9 I "s #N0 -S5 "s1 #N4 #N1 -M6 I "s #N0 -M10 S8 "s1 #N2 -S2 "s #N4 #N1 -M11 S5 "s #N0 -G12 S2 "s2 -G14 I F "main -{ -\ - j L15 -A16 S2 "s -A17 I "s - h A17 - h A16 M11 .S5 M6 .I A16 M11 .S5 M10 .S8 M9 .I +I -L15 -*/ - -typedef struct s s; - -struct s { - struct s1 { - int s; - struct s2 { - int s; - } s1; - } s; -} s2; - -#define s s - -int -main(void) -{ -#undef s - goto s; - struct s s; - { - int s; - return s; - } - return s.s.s + s.s.s1.s; - s: - { - s: return 0; - } -} diff --git a/cc1/tests/test016.c b/cc1/tests/test016.c @@ -1,95 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* -name: TEST016 -description: Basic pointer test -error: -test016.c:42: error: redefinition of 'func2' -test016.c:46: error: incompatible types when assigning -output: -G1 I "g -G3 I F "func1 -{ -\ -A4 I "x -A6 P "p - G1 #I1 :I - A4 #I1 :I - A6 A4 'P :P - A6 @I #I0 :I - y L7 A4 #I0 =I - h #I1 -L7 - A6 G1 'P :P - A6 @I #I0 :I - y L8 A6 #P0 !I - h #I1 -L8 - h #I0 -} -G9 I F "func2 -{ -\ -A10 I "x -A12 P "p -A14 P "pp - A10 #I1 :I - A12 A10 'P :P - A14 A12 'P :P - y L15 A12 #P0 =I - A14 @P @I #I0 :I -L15 - A12 #P0 :P - h A10 -} -*/ - -#line 1 - -int g; - -int -func1(void) -{ - int x; - int *p; - - g = 1; - x = 1; - p = &x; - *p = 0; - if (x) - return 1; - - p = &g; - *p = 0; - if (p == 0) - return 1; - return 0; -} - -int -func2(void) -{ - int x; - int *p; - int **pp; - - x = 1; - p = &x; - pp = &p; - if (p != 0) - **pp = 0; - p = 0; - return x; -} - -int -func2(void) -{ - char c; - int *p; - - p = &c; - return *p; -} diff --git a/cc1/tests/test017.c b/cc1/tests/test017.c @@ -1,54 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* -name: TEST017 -description: Basic test about pointers and structs -error: -output: -S2 "s1 #N4 #N1 -M3 I "y #N0 -M4 I "z #N2 -S6 "s2 #N4 #N2 -M8 P "p #N0 -G10 I F "main -{ -\ -A11 S2 "nested -A12 S6 "v - A12 M8 .P A11 'P :P - A12 M8 .P @S2 M3 .I #I1 :I - A12 M8 .P @S2 M4 .I #I2 :I - y L13 A11 M3 .I #I1 =I - h #I1 -L13 - y L14 A11 M4 .I #I2 =I - h #I2 -L14 - h #I0 -} -*/ - -#line 1 - -struct s1 { - int y; - int z; -}; - -struct s2 { - struct s1 *p; -}; - -int main() -{ - struct s1 nested; - struct s2 v; - v.p = &nested; - v.p->y = 1; - v.p->z = 2; - if (nested.y != 1) - return 1; - if (nested.z != 2) - return 2; - return 0; -} diff --git a/cc1/tests/test018.c b/cc1/tests/test018.c @@ -1,61 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* -name: TEST018 -description: Basic test for arrays -error: -output: -G2 I F "main -{ -\ -V3 K #N4 -V4 V3 #N2 -A5 V4 "arr -A7 P "p -A9 P "q -V10 I #N4 -A11 V10 "v - A7 A5 'P :P - A9 A5 'P #P4 +P #P3 +P :P - A5 'P #P4 +P #P3 +P @K #K2 :K - A11 #I2 :I - y L13 A5 'P #P4 +P #P3 +P @K gI #I2 =I - h #I1 -L13 - y L14 A7 #P4 +P #P3 +P @K gI #I2 =I - h #I1 -L14 - y L15 A9 @K gI #I2 =I - h #I1 -L15 - y L16 A11 #I2 =I - h #I1 -L16 - h #I0 -} -*/ - -#line 1 - -int -main() -{ - char arr[2][4], (*p)[4], *q; - int v[4]; - - p = arr; - q = &arr[1][3]; - arr[1][3] = 2; - v[0] = 2; - - if (arr[1][3] != 2) - return 1; - if (p[1][3] != 2) - return 1; - if (*q != 2) - return 1; - if (*v != 2) - return 1; - - return 0; -} diff --git a/cc1/tests/test019.c b/cc1/tests/test019.c @@ -1,62 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* -name: TEST019 -description: Basic test of constant folding in integer arithmetic operations -error: -test019.c:12: warning: division by 0 -test019.c:13: warning: division by 0 -output: -G2 I F "main -{ -\ -A3 I "i - A3 #I3 :I - A3 #I1 :I - A3 #I12 :I - A3 #I2 :I - A3 #I0 :I - A3 A3 #I0 %I :I - A3 A3 #I0 %I :I - A3 #I8 :I - A3 #I2 :I - A3 #I4 :I - A3 #IC :I - A3 #I8 :I - A3 #IFFFD :I - A3 #IFFF3 :I - A3 #I1 :I - A3 #I0 :I - A3 #I0 :I - A3 #I1 :I - A3 #I0 :I -} -*/ - -#line 1 - -int -main(void) -{ - int i; - - i = 1 + 2; - i = 2 - 1; - i = 3 * 6; - i = 10 / 5; - i = 10 % 5; - i = i % 0; - i = i % 0; - i = 1 << 3; - i = 8 >> 2; - i = 12 & 4; - i = 8 | 4; - i = 12 ^ 4; - i = -(3); - i = ~12; - i = 1 < 3; - i = 2 > 3; - i = 2 >= 3; - i = 2 <= 3; - i = 1 == 0; -} diff --git a/cc1/tests/test020.c b/cc1/tests/test020.c @@ -1,84 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* -name: TEST020 -description: Basic test for integer algebraic identities -error: -test020.c:82: warning: division by 0 -test020.c:83: warning: division by 0 -output: -G2 I F "main -{ -\ -A3 I "i - A3 A3 #I0 !I :I - A3 A3 #I0 !I #I1 ,I :I - A3 #I1 :I - A3 A3 #I0 !I :I - A3 A3 #I0 !I #I0 ,I :I - A3 A3 #I0 !I :I - A3 A3 #I0 !I :I - A3 #I0 :I - A3 A3 :I - A3 #I0 :I - A3 A3 :I - A3 #I0 :I - A3 A3 :I - A3 A3 :I - A3 A3 :I - A3 #I0 A3 -I :I - A3 A3 :I - A3 A3 :I - A3 A3 :I - A3 A3 :I - A3 A3 #I0 ,I :I - A3 A3 #I0 ,I :I - A3 A3 :I - A3 A3 :I - A3 A3 :I - A3 #I1 A3 /I :I - A3 A3 :I - A3 A3 :I - A3 A3 #I1 ,I :I - A3 A3 #I0 /I :I - A3 A3 #I0 %I :I -} -*/ - -int -main(void) -{ - int i; - - i = i || 0; - i = i || 4; - i = 4 || i; - i = 0 || i; - i = i && 0; - i = i && 4; - i = 4 && i; - i = 0 && i; - i = i << 0; - i = 0 << i; - i = i >> 0; - i = 0 >> i; - i = i + 0; - i = 0 + i; - i = i - 0; - i = 0 - i; - i = i | 0; - i = 0 | i; - i = i ^ 0; - i = 0 ^ i; - i = i * 0; - i = 0 * i; - i = i * 1; - i = 1 * i; - i = i / 1; - i = 1 / i; - i = i & ~0; - i = ~0 & i; - i = i % 1; - i = i / 0; - i = i % 0; -} diff --git a/cc1/tests/test021.c b/cc1/tests/test021.c @@ -1,44 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* -name: TEST021 -description: Basic test for char constants -comments: This test is done for z80 implementation -error: -output: -G2 I F "main -{ -\ -A3 K "uc -A4 C "sc - A3 #KFF :K - A3 #K23 :K - A3 #K1 :K - A3 #K1 :K - A3 #K41 :K - A4 #CFF :C - A4 #C23 :C - A4 #C1 :C - A4 #C1 :C - A4 #C41 :C -} -*/ - -int -main(void) -{ - unsigned char uc; - signed char sc; - - uc = -1; - uc = '\x23'; - uc = 1u; - uc = 1025; - uc = 'A'; - - sc = -1; - sc = '\x23'; - sc = 1u; - sc = 1025; - sc = 'A'; -} diff --git a/cc1/tests/test022.c b/cc1/tests/test022.c @@ -1,58 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* -name: TEST022 -description: Basic test for int constants -comments: This test is done for z80 data types -error: -output: -G2 I F "main -{ -\ -A3 I "i -A4 N "u - A3 #I1 :I - A3 #IFFFF :I - A3 #IFFFF :I - A3 #IFFFF :I - A3 #IFFFF :I - A3 #I3 :I - A3 #I1 :I - A3 #I0 :I - A4 #N1 :N - A4 #NFFFF :N - A4 #NFFFF :N - A4 #NFFFF :N - A4 #NFFFF :N - A4 #N0 :N - A4 #N3 :N - A4 #N0 :N - h #I0 -} -*/ - -int -main(void) -{ - int i; - unsigned u; - - i = 1; - i = -1; - i = -1l; - i = -1u; - i = -1ll; - i = 32766 + 1 & 3; - i = (int) 32768 < 0; - i = -1u < 0; - - u = 1; - u = -1; - u = -1l; - u = -1u; - u = -1ll; - u = (unsigned) 32768 < 0; - u = 32766 + 1 & 3; - u = -1u < 0; - return 0; -} diff --git a/cc1/tests/test023.c b/cc1/tests/test023.c @@ -1,58 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* -name: TEST023 -description: Basic test for long constants -comments: This test is done for z80 data types -error: -output: -G2 I F "main -{ -\ -A3 W "i -A4 Z "u - A3 #W1 :W - A3 #WFFFFFFFF :W - A3 #WFFFFFFFF :W - A3 #WFFFF :W - A3 #WFFFFFFFF :W - A3 #W3 :W - A3 #W1 :W - A3 #W0 :W - A4 #Z1 :Z - A4 #ZFFFFFFFF :Z - A4 #ZFFFFFFFF :Z - A4 #ZFFFF :Z - A4 #ZFFFFFFFF :Z - A4 #Z3 :Z - A4 #Z1 :Z - A4 #Z0 :Z - h #I0 -} -*/ - -int -main(void) -{ - long i; - unsigned long u; - - i = 1; - i = -1; - i = -1l; - i = -1u; - i = -1ll; - i = (1ll << 32) - 1 & 3; - i = (long) ((1ll << 32) - 1) < 0; - i = -1u < 0; - - u = 1; - u = -1; - u = -1l; - u = -1u; - u = -1ll; - u = (1ll << 32) - 1 & 3; - u = (long) ((1ll << 32) - 1) < 0; - u = -1u < 0; - return 0; -} diff --git a/cc1/tests/test024.c b/cc1/tests/test024.c @@ -1,54 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* -name: TEST024 -description: Basic test for long long constants -comments: This test is done for z80 data types -error: -output: -G2 I F "main -{ -\ -A3 Q "i -A4 O "u - A3 #Q1 :Q - A3 #QFFFFFFFFFFFFFFFF :Q - A3 #QFFFFFFFFFFFFFFFF :Q - A3 #QFFFF :Q - A3 #QFFFFFFFFFFFFFFFF :Q - A3 #Q3 :Q - A3 #Q1 :Q - A4 #O1 :O - A4 #OFFFFFFFFFFFFFFFF :O - A4 #OFFFFFFFFFFFFFFFF :O - A4 #OFFFF :O - A4 #OFFFFFFFFFFFFFFFF :O - A4 #O3 :O - A4 #O0 :O - h #I0 -} -*/ - -int -main(void) -{ - long long i; - unsigned long long u; - - i = 1; - i = -1; - i = -1l; - i = -1u; - i = -1ll; - i = -1ll & 3; - i = -1ll < 0; - - u = 1; - u = -1; - u = -1l; - u = -1u; - u = -1ll; - u = -1llu & 3; - u = -1llu < 0; - return 0; -} diff --git a/cc1/tests/test025.c b/cc1/tests/test025.c @@ -1,66 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* -name: TEST025 -descritpion: Test of ifdef and ifndef -error: -output: -G1 I "a -G2 I "b -G3 I "c -G4 I "d -G5 I "_1 -G6 I "_2 -G7 I "e_ -G8 I "f_ -G9 I "h -G10 I "i -*/ - -#define FOO - -#ifdef FOO - int a; - int b; - #undef FOO - #ifndef FOO - int c; - int d; - #else - int e; - int f; - #endif - int _1; - int _2; - #ifdef FOO - int c_; - int d_; - #else - int e_; - int f_; - #endif - int h; - int i; -#else - int j; - int k; - #ifdef FOO - int l; - int m; - #else - int n; - int o; - #endif - int p; - int q; - #ifndef FOO - int r; - int s; - #else - int t; - int u; - #endif - int v; - int w; -#endif - diff --git a/cc1/tests/test026.c b/cc1/tests/test026.c @@ -1,43 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* -name: TEST026 -descritpion: Test of predefined cpp macros -error: -output: -G3 I F "main -{ -\ -A4 I "y -A6 P "p -V7 K #NA -Y8 V7 " ( - #"test026.c - #K00 -) - A6 Y8 'P :P - A4 #I24 :I - A4 #I1 :I - A4 #I1 :I - A4 #I1 :I - A4 #I1 :I -} -*/ - -#define x(y) (y) - -int -main(void) -{ - int y; - char *p; - - p = __FILE__; - y = __LINE__; -/* p = __DATE__; __DATE__ generates different value each time */ - y = __STDC__; -/* p = __TIME__; __TIME__ generates different value each time */ - y = __STDC_HOSTED__; - y = __SCC__; - y = x(1); -} diff --git a/cc1/tests/test027.c b/cc1/tests/test027.c @@ -1,31 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* -name: TEST027 -description: Test of cpp stringizer -error: -output: -G3 I F "main -{ -\ -A5 P "p -V6 K #N19 -Y7 V6 " ( - #"hello is better than bye - #K00 -) - A5 Y7 'P :P - h A5 @K gI -} -*/ - -#define x(y) #y - -int -main(void) -{ - char *p; - p = x(hello) " is better than bye"; - - return *p; -} diff --git a/cc1/tests/test028.c b/cc1/tests/test028.c @@ -1,28 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* -name: TEST028 -description: Test of reinterpretation in define -error: -output: -G6 P F "foo -{ -\ -V7 K #N3 -Y10 V7 " ( - #"hi - #K00 -) - h Y10 'P -} -*/ - - -#define M(x) x -#define A(a,b) a(b) - -char * -foo(void) -{ - return A(M,"hi"); -} diff --git a/cc1/tests/test029.c b/cc1/tests/test029.c @@ -1,39 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* -name: TEST029 -description: Test of nested expansion and refusing macro without arguments -comments: f(2) will expand to 2*g, which will expand to 2*f, and in this - moment f will not be expanded because the macro definition is - a function alike macro, and in this case there is no arguments. -error: -test029.c:32: warning: expression without side effects -test029.c:37: error: redefinition of 'f1' -test029.c:38: error: 'f' undeclared -test029.c:38: warning: expression without side effects -output: -G3 I F "f1 -{ -\ -A4 I "f - A4 #I2 *I -} -*/ - - -#define f(a) a*g -#define g f - -int -f1(void) -{ - int f; - - f(2); -} - -int -f1(void) -{ - f(2); -} diff --git a/cc1/tests/test030.c b/cc1/tests/test030.c @@ -1,60 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* -name: TEST030 -description: Basic test for vararg functions -error: -output: -S2 "foo #N18 #N2 -M3 I "i #N0 -M4 I "j #N2 -M5 I "k #N4 -M7 P "p #N6 -M8 J "v #N8 -G14 I F "f1 -{ -A9 S2 "f -A11 P "p -A12 I "n -\ - y L15 A9 M3 .I A11 @S2 M3 .I =I - h #I0 -L15 - h A11 @S2 M4 .I A12 +I -} -G17 I F "main -{ -\ -A18 S2 "f - A18 M3 .I A18 M4 .I #I1 :I :I - G14 A18 pS2 A18 'P pP #I2 pI cI - G14 A18 pS2 A18 'P pP #I2 pI #I1 pI A18 pS2 A18 'P pP cI - h #I0 -} -*/ - -struct foo { - int i, j, k; - char *p; - float v; -}; - -int -f1(struct foo f, struct foo *p, int n, ...) -{ - if (f.i != p->i) - return 0; - return p->j + n; -} - -int -main(void) -{ - struct foo f; - - f.i = f.j = 1; - f1(f, &f, 2); - f1(f, &f, 2, 1, f, &f); - - return 0; -} diff --git a/cc1/tests/test031.c b/cc1/tests/test031.c @@ -1,26 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* -name: TEST031 -description: Test concatenation in preprocessor -error: -TODO -output: - -*/ - -#define CAT(x,y) x ## y -#define XCAT(x,y) CAT(x,y) -#define FOO foo -#define BAR bar - -int -main(void) -{ - int foo, bar, foobar; - - CAT(foo,bar) = foo + bar; - XCAT(FOO,BAR) = foo + bar; - return 0; -} - diff --git a/cc1/tests/test032.c b/cc1/tests/test032.c @@ -1,31 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* -name: TEST032 -description: test special characters @ and $ in macro definitions -error: -output: -G3 I F "main -{ -\ -V6 K #N2C -Y7 V6 " ( - #"This is a string $ or # or ##and it is ok ! - #K00 -) -A5 P "p - A5 Y7 'P :P - h A5 #P0 !I -} -*/ - -#define M1(x) "This is a string $ or # or ##" ## #x - -int -main(void) -{ - char *p = M1(and it is ok!); - - return p != 0; -} - diff --git a/cc1/tests/test033.c b/cc1/tests/test033.c @@ -1,20 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* -name: TEST033 -description: test for #if defined() -error: -output: -G1 I "c -*/ - -#if defined(FOO) -int a; -#elif !defined(FOO) && defined(BAR) -int b; -#elif !defined(FOO) && !defined(BAR) -int c; -#else -int d; -#endif - diff --git a/cc1/tests/test034.c b/cc1/tests/test034.c @@ -1,48 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* -name: TEST034 -description: Basic test for incomplete structures -error: -test034.c:48: error: declared variable 'bar' of incomplete type -test034.c:48: error: redeclaration of 'bar' -output: -X3 S2 "x -X5 I F "foo -G6 I F "main -{ -\ -X7 S2 "x - h X7 'P #P0 !I -} -S2 "X #N2 #N1 -M9 I "v #N0 -G5 I F "foo -{ -\ - X3 M9 .I #I0 :I - h X3 M9 .I -} -X13 S11 "bar2 -*/ - -extern struct X x; -int foo(); - -int main() -{ - extern struct X x; - return &x != 0; -} - -struct X {int v;}; - -int foo() -{ - x.v = 0; - return x.v; -} - -typedef struct bar bar; -extern bar bar2; -bar bar; diff --git a/cc1/tests/test035.c b/cc1/tests/test035.c @@ -1,51 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* -name: TEST035 -description: Basic test for enumerations -error: -output: -G7 I F "main -{ -\ -A8 I "e - A8 #I3 :I - y L9 A8 #I1 =I - h #I0 -L9 - y L10 A8 #I0 =I - h #I1 -L10 - y L11 A8 #I2 =I - h #I2 -L11 - y L12 A8 #I3 =I - h #I3 -L12 - h #I0 -} -*/ - -enum E { - x, - y = 2, - z, -}; - - -int -main() -{ - enum E e = 3; - - if (e !=1) - return 0; - if (e != x) - return 1; - if (e != y) - return 2; - if (e != z) - return 3; - - return x; -} diff --git a/cc1/tests/test036.c b/cc1/tests/test036.c @@ -1,75 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* -name: TEST036 -description: Duff's device -error: -test036.c:59: warning: type defaults to 'int' in declaration -output: -G5 I F "send -{ -R1 P "to -R2 P "from -R3 I "count -\ -R7 I "n - R7 R3 #I7 +I #I8 /I :I - s R3 #I8 %I - v L9 #I0 -L9 - e -L10 - R1 @I R2 #P2 :iP @I :I - v L12 #I7 -L12 - R1 @I R2 #P2 :iP @I :I - v L13 #I6 -L13 - R1 @I R2 #P2 :iP @I :I - v L14 #I5 -L14 - R1 @I R2 #P2 :iP @I :I - v L15 #I4 -L15 - R1 @I R2 #P2 :iP @I :I - v L16 #I3 -L16 - R1 @I R2 #P2 :iP @I :I - v L17 #I2 -L17 - R1 @I R2 #P2 :iP @I :I - v L18 #I1 -L18 - R1 @I R2 #P2 :iP @I :I - y L10 R7 #I1 :-I #I0 >I - b -L11 - t L8 -L8 -} -*/ - -/* Disgusting, no? But it compiles and runs just fine. I feel a combination of - pride and revulsion at this discovery. If no one's thought of it before, - I think I'll name it after myself. - It amazes me that after 10 years of writing C there are still - little corners that I haven't explored fully. - - Tom Duff */ - -send(to, from, count) - register short *to, *from; - register count; -{ - register n=(count+7)/8; - switch(count%8){ - case 0: do{*to = *from++; - case 7: *to = *from++; - case 6: *to = *from++; - case 5: *to = *from++; - case 4: *to = *from++; - case 3: *to = *from++; - case 2: *to = *from++; - case 1: *to = *from++; - }while(--n>0); - } -} diff --git a/cc1/tests/test037.c b/cc1/tests/test037.c @@ -1,37 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* -name: TEST037 -description: Basic sizeof test -comments: This test is based in z80 sizes -error: -test037.c:30: warning: conditional expression is constant -test037.c:32: warning: conditional expression is constant -test037.c:34: warning: conditional expression is constant -output: -G2 I F "main -{ -\ - y L3 #I1 - h #I1 -L3 - y L4 #I1 - h #I2 -L4 - y L5 #I1 - h #I3 -L5 - h #I0 -} -*/ - -int main() -{ - if(sizeof(0) != 2) - return 1; - if(sizeof(char) != 1) - return 2; - if(sizeof(int) != 2) - return 3; - return 0; -} diff --git a/cc1/tests/test038.c b/cc1/tests/test038.c @@ -1,45 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* -name: TEST038 -description: Basic test for tentative definitions -error: -test038.c:45: error: redeclaration of 'x' -output: -G1 I "x -G1 I "x ( - #I0 -) -X3 I F "main -G5 P F "foo -{ -\ - h X3 'P -} -G3 I F "main -{ -\ - G1 #I0 :I - h G1 -} -*/ - -int x; -int x = 0; -int x; - -int main(); - -void * -foo() -{ - return &main; -} - -int -main() -{ - x = 0; - return x; -} -int x = 1; diff --git a/cc1/tests/test039.c b/cc1/tests/test039.c @@ -1,59 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* -name: TEST039 -description: Test of integer constants -comments: This test is done for z80 sizes -error: -output: -G2 I F "main -{ -\ -A3 I "i -A4 N "u -A5 W "l -A6 Z "ul -A7 Q "ll -A8 O "ull - A3 #I1 :I - A3 #I1 :I - A4 #N1 :N - A4 #N1 :N - A5 #W1 :W - A5 #W0 :W - A4 #N0 :N - A6 #Z1 :Z - A5 #W1 :W - A7 #Q0 :Q - A6 #Z0 :Z - A8 #O1 :O - A8 #O1 :O - h #I0 -} -*/ - -int -main(void) -{ - int i; - unsigned u; - long l; - unsigned long ul; - long long ll; - unsigned long long ull; - - i = 1; - i = 1u; - u = 1u; - u = 1; - l = 1l; - l = 0xFFFF + 1; - u = 0xFFFF + 1; - ul = 1ul; - l = 1ul; - ll = 0xFFFFFFFF + 1; - ul = 0xFFFFFFFF + 1; - ull = 1lul; - ull = 1; - return 0; -} diff --git a/cc1/tests/test040.c b/cc1/tests/test040.c @@ -1,34 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* -name: TEST040 -description: Test for bug parsing typenames in struct definition -error: -output: -S2 "List #NC #N2 -M4 I "len #N0 -M6 P "head #N2 -M7 P "back #N4 -G9 I F "main -{ -\ -A10 S2 "List - h A10 M4 .I -} -*/ - -typedef struct List List; -struct List { - int len; - struct List *head; - List *back; -}; - -int -main(void) -{ - List List; - - return List.len; -} - diff --git a/cc1/tests/test041.c b/cc1/tests/test041.c @@ -1,54 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* -name: TEST041 -description: Test for bug parsing ternary operators -error: -test041.c:51: error: type mismatch in conditional expression -test041.c:51: error: incompatible types when assigning -test041.c:52: error: used struct/union type value where scalar is required -test041.c:52: warning: expression without side effects -test041.c:53: warning: 'i' defined but not used -test041.c:53: warning: 'foo' defined but not used -test041.c:53: warning: 's' defined but not used -output: -G2 I F "main -{ -\ -A3 I "i -A5 P "q -A7 P "s -A8 P "p -S10 "foo #N2 #N1 -M11 I "i #N0 -A12 S10 "foo - A3 A3 #I0 !I #W0 #W0 ?W gI :I - A8 A3 #I0 !I #P0 #P0 ?P :P - A8 A3 #I0 !I #P0 #P0 ?P :P - A8 A3 #I0 !I #P0 #P0 ?P :P - A5 A3 #I0 !I #P0 A8 ?P :P - A5 A3 #I0 !I A8 #P0 ?P :P - A5 A3 #I0 !I A5 #P0 ?P :P - A5 A3 #I0 !I #P0 A5 ?P :P -*/ - -int -main(void) -{ - int i, *q; - char *s; - void *p; - struct foo {int i;} foo; - - i = i ? 0 : 0l; - p = i ? (void *) 0 : 0; - p = i ? 0 : (void *) 0; - p = i ? 0 : (const void *) 0; - q = i ? 0 : p; - q = i ? p : 0; - q = i ? q : 0; - q = i ? 0 : q; - p = i ? 2 : p; - foo ? 1 : 2; -} - diff --git a/cc1/tests/test042.c b/cc1/tests/test042.c @@ -1,21 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* -name: TEST042 -description: Test for bug parsing ternary operators -error: -test042.c:20: error: bad type conversion requested -output: -G2 I F "main -{ -\ -X4 0 F "f -*/ - -int -main(void) -{ - void f(void); - - return (int) f(); -} diff --git a/cc1/tests/test043.c b/cc1/tests/test043.c @@ -1,35 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* -name: TEST043 -description: Test for double typedef (taken from plan9 kernel) -error: -output: -S2 "Clock0link #N8 #N2 -M6 P "clock #N0 -M8 P "link #N2 -G9 S2 "cl0 -G11 I F "main -{ -\ - G9 M6 .P @F c0 - h #I0 -} -*/ - -typedef struct Clock0link Clock0link; -typedef struct Clock0link { - void (*clock)(void); - Clock0link* link; -} Clock0link; - - - -Clock0link cl0; - -int -main(void) -{ - (*cl0.clock)(); - return 0; -} diff --git a/cc1/tests/test044.c b/cc1/tests/test044.c @@ -1,34 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* -name: TEST044 -description: Test of corner cases in #if -error: -test044.c:17: warning: division by 0 -test044.c:21: warning: division by 0 -test044.c:25: warning: division by 0 -test044.c:31: error: parameter of #if is not an integer constant expression -test044.c:32: error: #error 3 != (1,2,3) -output: -*/ - -/* These should be accepted */ - - #if 0 != (0 && (0/0)) - #error 0 != (0 && (0/0)) - #endif - - #if 1 != (-1 || (0/0)) - #error 1 != (-1 || (0/0)) - #endif - - #if 3 != (-1 ? 3 : (0/0)) - #error 3 != (-1 ? 3 : (0/0)) - #endif - -/* This is invalid code (it is a constraint violation) */ - - #if 3 != (1,2,3) - #error 3 != (1,2,3) - #endif - diff --git a/cc1/tests/test045.c b/cc1/tests/test045.c @@ -1,31 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* -name: TEST045 -description: Basic test of initializers -error: -output: -G1 I "x ( - #I5 -) -G3 I F "main -{ -\ - y L4 G1 #I5 =I - h #I1 -L4 - h #I0 -} -*/ - - - -int x = 5; - -int -main() -{ - if(x != 5) - return 1; - return 0; -} diff --git a/cc1/tests/test046.c b/cc1/tests/test046.c @@ -1,42 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* -name: TEST046 -description: Basic test for initializators -error: -output: -V1 I #N3 -G2 V1 "x ( - #I1 - #I2 - #I3 -) -G4 I F "main -{ -\ - y L5 G2 #I1 =I - h #I1 -L5 - y L7 G2 'P #P2 +P @I #I2 =I - h #I2 -L7 - y L8 G2 'P #P4 +P @I #I3 =I - h #I3 -L8 - h #I0 -} -*/ - -int x[3] = {1, 2, 3}; - -int -main() -{ - if(x[0] != 1) - return 1; - if(x[1] != 2) - return 2; - if(x[2] != 3) - return 3; - return 0; -} diff --git a/cc1/tests/test047.c b/cc1/tests/test047.c @@ -1,53 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* -name: TEST047 -description: Basic test for initializer -error: -output: -S2 "S #N6 #N1 -M3 I "a #N0 -M4 I "b #N2 -M5 I "c #N4 -G6 S2 "x ( - #I1 - #I2 - #I3 -) -G8 I F "main -{ -\ - y L9 G6 M3 .I #I1 =I - h #I1 -L9 - y L10 G6 M4 .I #I2 =I - h #I2 -L10 - y L11 G6 M5 .I #I3 =I - h #I3 -L11 - h #I0 -} -*/ - - - -struct S { - int a; - int b; - int c; -}; - -struct S x = {1, 2, 3}; - -int -main() -{ - if(x.a != 1) - return 1; - if(x.b != 2) - return 2; - if(x.c != 3) - return 3; - return 0; -} diff --git a/cc1/tests/test048.c b/cc1/tests/test048.c @@ -1,44 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* -name: TEST048 -description: Basic test for initializer -error: -output: -S2 "S #N4 #N1 -M3 I "a #N0 -M4 I "b #N2 -V5 S2 #N1 -G6 V5 "x ( - #I1 - #I2 -) -G8 I F "main -{ -\ - y L9 G6 M3 .I #I1 =I - h #I1 -L9 - y L11 G6 M4 .I #I2 =I - h #I2 -L11 - h #I0 -} -*/ - -struct S { - int a; - int b; -}; - -struct S x[1] = {{1, 2}}; - -int -main() -{ - if(x[0].a != 1) - return 1; - if(x[0].b != 2) - return 2; - return 0; -} diff --git a/cc1/tests/test049.c b/cc1/tests/test049.c @@ -1,33 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* -name: TEST049 -description: Basic test for initializer -error: -output: -G1 I "x ( - #I5 -) -G3 P "p ( - G1 'P -) -G5 I F "main -{ -\ - y L6 G3 @I #I5 =I - h #I1 -L6 - h #I0 -} -*/ - -int x = 5; -int *p = &x; - -int -main() -{ - if(*p != 5) - return 1; - return 0; -} diff --git a/cc1/tests/test050.c b/cc1/tests/test050.c @@ -1,22 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* -name: TEST050 -description: Basic test for initializer -error: -TODO: -output: -*/ - -struct S { int a; int b; }; -struct S s = (struct S){1, 2}; - -int -main() -{ - if(s.a != 1) - return 1; - if(s.b != 2) - return 2; - return 0; -} diff --git a/cc1/tests/test051.c b/cc1/tests/test051.c @@ -1,42 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* -name: TEST051 -description: Basic test for initializer -error: -output: -V1 I #N3 -G2 V1 "arr ( - #I0 - #I1 - #I2 -) -G4 I F "main -{ -\ - y L5 G2 #I0 =I - h #I1 -L5 - y L7 G2 'P #P2 +P @I #I1 =I - h #I2 -L7 - y L8 G2 'P #P4 +P @I #I2 =I - h #I3 -L8 - h #I0 -} -*/ - -int arr[3] = {[2] = 2, [0] = 0, [1] = 1}; - -int -main() -{ - if(arr[0] != 0) - return 1; - if(arr[1] != 1) - return 2; - if(arr[2] != 2) - return 3; - return 0; -} diff --git a/cc1/tests/test052.c b/cc1/tests/test052.c @@ -1,52 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* -name: TEST052 -description: Basic test for initializer -error: -output: -S2 "S #N4 #N1 -M3 I "a #N0 -M4 I "b #N2 -V5 S2 #N2 -G6 V5 "arr ( - #I1 - #I2 - #I3 - #I4 -) -G8 I F "main -{ -\ - y L9 G6 M3 .I #I1 =I - h #I1 -L9 - y L11 G6 M4 .I #I2 =I - h #I2 -L11 - y L12 G6 'P #P4 +P @S2 M3 .I #I3 =I - h #I3 -L12 - y L13 G6 'P #P4 +P @S2 M4 .I #I4 =I - h #I4 -L13 - h #I0 -} -*/ - -struct S {int a; int b;}; -struct S arr[2] = {[1] = {3, 4}, [0] = {1, 2}}; - -int -main() -{ - if(arr[0].a != 1) - return 1; - if(arr[0].b != 2) - return 2; - if(arr[1].a != 3) - return 3; - if(arr[1].b != 4) - return 4; - return 0; -} diff --git a/cc1/tests/test053.c b/cc1/tests/test053.c @@ -1,39 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* -name: TEST053 -description: Basic test for initializer -error: -output: -S2 "S #N4 #N1 -M3 I "a #N0 -M4 I "b #N2 -G5 S2 "s ( - #I1 - #I2 -) -G7 I F "main -{ -\ - y L8 G5 M3 .I #I1 =I - h #I1 -L8 - y L9 G5 M4 .I #I2 =I - h #I2 -L9 - h #I0 -} -*/ - -struct S {int a; int b;}; -struct S s = { .b = 2, .a = 1}; - -int -main() -{ - if(s.a != 1) - return 1; - if(s.b != 2) - return 2; - return 0; -} diff --git a/cc1/tests/test054.c b/cc1/tests/test054.c @@ -1,24 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* -name: TEST054 -description: Basic test for initializer -error: -TODO -output: - -*/ - -struct S { int a; int b; }; -struct S *s = &(struct S) { 1, 2 }; - -int -main() -{ - if(s->a != 1) - return 1; - if(s->b != 2) - return 2; - return 0; -} - diff --git a/cc1/tests/test055.c b/cc1/tests/test055.c @@ -1,45 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* -name: TEST055 -description: Basic test for initializer -error: -TODO -output: - -*/ - -struct S1 { - int a; - int b; -}; -struct S2 { - struct S1 s1; - struct S1 *ps1; - int arr[2]; -}; -struct S1 gs1 = (struct S1) {.a = 1, 2}; -struct S2 *s = &(struct S2) { - {.b = 2, .a = 1}, - &gs1, - {[0] = 1, 1+1} -}; - -int -main() -{ - if(s->s1.a != 1) - return 1; - if(s->s1.b != 2) - return 2; - if(s->ps1->a != 1) - return 3; - if(s->ps1->b != 2) - return 4; - if(s->arr[0] != 1) - return 5; - if(s->arr[1] != 2) - return 6; - return 0; -} - diff --git a/cc1/tests/test056.c b/cc1/tests/test056.c @@ -1,50 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* -name: TEST056 -desciption: Test of overlaying designators -error: -output: -V6 K #N3 -S2 "S #NB #N1 -M3 I "a #N0 -M4 I "b #N2 -M5 I "c #N4 -M7 V6 "d #N6 -M8 I "e #N9 -G9 S2 "s ( - #I1 - #I2 - #I0 - #K4 - #K6 - #K0 - #I0 -) -G11 V10 "m ( -) -G13 I F "main -{ -\ - h G9 M7 .V6 'P #P2 +P @K gI gN #N0 =I -} -*/ - -struct S { - int a, b, c; - char d[3]; - int e; -} s = { - .a = 1, - .b = 2, - .d = {[0] = 3, [2] = 5}, - .d = {[0] = 4, [1] = 6} -}; - -char m[] = {}; - -int -main(void) -{ - return sizeof(m) == s.d[2]; -} diff --git a/cc1/tests/test057.c b/cc1/tests/test057.c @@ -1,46 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* -name: TEST057 -description: test of initialization of incomplete arrays -error: -output: -V1 I #N3 -G3 V2 "arr1 ( - #I2 - #I7 - #I5 - #I5 - #I1 - #I2 -) -G4 V2 "arr2 ( - #I2 - #I7 - #I5 - #I5 - #I1 - #I2 -) -G6 I F "main -{ -\ - h G3 'P #P6 +P #P4 +P @I G4 'P #P6 +P #P6 +P @I !I -} -*/ - -int arr1[][3] = { - { 2, 7, 5, }, - { 5, 1, 2, }, -}; - -int arr2[2][3] = { - 2, 7, 5, - 5, 1, 2 -}; - -int -main(void) -{ - return !(arr1[1][2] == arr2[1][3]); -} diff --git a/cc1/tests/test058.c b/cc1/tests/test058.c @@ -1,65 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* -name: TEST058 -description: Test of initialization mixing designators and sequence -error: -output: -V1 I #N5 -V2 V1 #N3 -G4 V3 "arr ( - #I0 - #I0 - #I3 - #I5 - #I0 - #I1 - #I0 - #I0 - #I6 - #I7 - #I0 - #I0 - #I0 - #I0 - #I0 - #I1 - #I2 - #I0 - #I0 - #I0 - #I0 - #I0 - #I0 - #I0 - #I7 - #I0 - #I0 - #I0 - #I0 - #I0 -) -G6 I F "main -{ -\ - h G4 'P #PA +P #P8 +P @I G4 'P #P1E +P #PA +P #P8 +P @I !I -} -*/ - -int arr[][3][5] = { - { - { 0, 0, 3, 5 }, - { 1, [3] = 6, 7 }, - }, - { - { 1, 2 }, - { [4] = 7, }, - }, -}; - - -int -main(void) -{ - return !(arr[0][1][4] == arr[1][1][4]); -} diff --git a/cc1/tests/test059.c b/cc1/tests/test059.c @@ -1,17 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* -name: TEST059 -description: Test of initalizers for strings -error: -TODO -output: - -*/ - -char s0[] = "foo"; -char s1[7] = "foo"; -char s2[2] = "foo"; -char s3[] = {"foo"}; -char *p = "foo"; -int m[] = "foo"; diff --git a/cc1/tests/test060.c b/cc1/tests/test060.c @@ -1,28 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* -name: TEST060 -description: Test for correctness of #line -error: -output: -G2 I F "main -{ -\ - h #I0 -} -*/ - -#undef line -#define line 1000 - -#line line -#if 1000 != __LINE__ - #error " # line line" not work as expected -#endif - -int -main() -{ - return 0; -} - diff --git a/cc1/tests/test061.c b/cc1/tests/test061.c @@ -1,24 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* -name: TEST061 -description: Test for macros without arguments but with parenthesis -error: -output: -G3 I F "main -{ -\ - h #I1 -} -*/ - -#define X (2) -#define L (0) -#define H (1) -#define Q(x) x - -int -main(void) -{ - return X == L + H + Q(1); -} diff --git a/cc1/tests/test062.c b/cc1/tests/test062.c @@ -1,24 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* -name: TEST062 -description: Test for hexadecimal numbers in upper and lower case -error: -output: -G2 I F "main -{ -\ - h #I1 -} -*/ - -int -main(void) -{ - return 0xa == 0xA && - 0xb == 0xB && - 0xc == 0xC && - 0xd == 0xD && - 0xe == 0xE && - 0xf == 0xF; -} diff --git a/cc1/tests/test063.c b/cc1/tests/test063.c @@ -1,12 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* -name: TEST063 -description: Test a comment that goes beyond of the end of an included file -error: -test063.h:9: error: unterminated comment -test063.c:12: error: #endif expected -output: -*/ - -#include "test063.h" diff --git a/cc1/tests/test063.h b/cc1/tests/test063.h @@ -1,9 +0,0 @@ - -#ifndef TEST_H_ -#define TEST_H_ - -/* - This is an unterminated comment. - - -#endif diff --git a/cc1/tests/test064.c b/cc1/tests/test064.c @@ -1,32 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* -name: TEST064 -description: Test function alike macro without parenthesis -error: -output: -S1 " #N2 #N1 -M2 I "f #N0 -G5 I F "main -{ -\ -A6 S1 "s - A6 M2 .I #I0 :I - h A6 M2 .I -} -*/ - -#define x f -#define y() f - -typedef struct { int f; } S; - -int -main() -{ - S s; - - s.x = 0; - return s.y(); -} - diff --git a/cc1/tests/test065.c b/cc1/tests/test065.c @@ -1,66 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* -name: TEST065 -description: Test decay mixed with * operators -error: -test065.c:65: error: increment 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]; -} diff --git a/cc1/tests/test066.c b/cc1/tests/test066.c @@ -1,55 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* -name: TEST066 -description: Test cpp defined operator -error: -test066.c:53: error: operator 'defined' requires an identifier -test066.c:53: error: expected ')' before '<EOF>' -output: -G1 I "x ( - #I0 -) -G3 I F "main -{ -\ - h #I0 -*/ - - -#if defined X -X -#endif - -#if defined(X) -X -#endif - -#if X -X -#endif - -#define X 0 - -#if X -X -#endif - -#if defined(X) -int x = 0; -#endif - -#undef X -#define X 1 - -#if X -int -main() -{ - return 0; -} -#endif - -#if defined (1) -#error 1 is defined -#endif diff --git a/cc1/tests/update.sh b/cc1/tests/update.sh @@ -1,26 +0,0 @@ -#!/bin/sh -# See LICENSE file for copyright and license details. - -out=/tmp/$$.out -err=/tmp/$$.err - -trap "rm -f $out $err" EXIT INT QUIT HUP - -case $# in -0) - echo "usage: update.sh test ..." >&2 - exit 1 - ;; -*) - for i - do - ../cc1-z80 -I./ -w $i >$out 2>$err - (echo '/^error/+;/^output/-c' - cat $err - printf ".\n" - echo '/^output/+;/^\*\//-c' - cat $out - printf ".\nw\n") | ed -s $i - done - ;; -esac diff --git a/tests/error/0020-storage.c b/tests/error/0020-storage.c @@ -0,0 +1,37 @@ +int a; +static char b; +extern int c; +typedef unsigned e; + +int +func1(void) +{ + auto h; + static char i; + register long j; + extern int k; + static unsigned long a; + return 0; +} + +void +func2(register int par) +{ + int par; +} + +static void +func3(register int par) +{ +} + +register short d; + +register void +func4(static int par) +{ + static register f; +} + +short d; +char d; diff --git a/tests/error/0021-namespace.c b/tests/error/0021-namespace.c @@ -0,0 +1,29 @@ +typedef struct s s; + +struct s { + struct s1 { + int s; + struct s2 { + int s; + } s1; + } s; +} s2; + +#define s s + +int +main(void) +{ +#undef s + goto s; + struct s s; + { + int s; + return s; + } + return s.s.s + s.s.s1.s; + s: + { + s: return 0; + } +} diff --git a/tests/error/0021-void.c b/tests/error/0021-void.c @@ -0,0 +1,7 @@ +int +main(void) +{ + void f(void); + + return (int) f(); +} diff --git a/tests/error/0022-cpp-if.c b/tests/error/0022-cpp-if.c @@ -0,0 +1,9 @@ +#if 3 != (1,2,3) + #error 3 != (1,2,3) +#endif + +int +main() +{ + return 0; +} diff --git a/tests/error/0023-include.c b/tests/error/0023-include.c @@ -0,0 +1,7 @@ + +/* + * Test a comment that goes beyond of the end of an + * included file + */ + +#include "0023-include.h" diff --git a/tests/error/0023-include.h b/tests/error/0023-include.h @@ -0,0 +1,8 @@ +#ifndef TEST_H_ +#define TEST_H_ + +/* + This is an unterminated comment. + + +#endif diff --git a/tests/error/scc-tests.lst b/tests/error/scc-tests.lst @@ -17,3 +17,7 @@ 0017-duplicatefunc.c 0018-voidparam.c [TODO] 0019-kr_names.c +0020-storage.c [TODO] +0021-void.c [TODO] +0022-cpp-if.c [TODO] +0023-include.c [TODO] diff --git a/tests/execute/0039-sizeof.c b/tests/execute/0039-sizeof.c @@ -1,10 +1,17 @@ int main() { - int x; - if((sizeof (int) - 4)) + int x, *p; + + if (sizeof(0) < 2) return 1; - if((sizeof (&x) - 8)) + if (sizeof 0 < 2) + return 1; + if (sizeof(char) < 1) + return 1; + if (sizeof(int) - 2 < 0) + return 1; + if (sizeof(&x) != sizeof p) return 1; return 0; } diff --git a/tests/execute/0131-hello.c b/tests/execute/0131-hello.c @@ -0,0 +1,8 @@ +#include <stdio.h> + +int +main(void) +{ + printf("hello world\n"); + return 0; +} diff --git a/tests/execute/0132-forward.c b/tests/execute/0132-forward.c @@ -0,0 +1,21 @@ +struct S *x; +struct S { + int i; + struct S *next; +}; + +int +main(void) +{ + struct S y, *p; + unsigned n; + + y.i = 0; + y.next = 0; + x = &y; + *x = y; + + for (n = 0, p = &y; p; ++n, p = p->next) + /* nothing */; + return n; +} diff --git a/tests/execute/0133-ftn-ptr.c b/tests/execute/0133-ftn-ptr.c @@ -0,0 +1,17 @@ +int +foo(void) +{ + return 42; +} + +int +bar(void) +{ + return 24; +} + +int +main(void) +{ + return (1 ? foo : bar)(); +} diff --git a/tests/execute/0134-arith.c b/tests/execute/0134-arith.c @@ -0,0 +1,37 @@ + +int +main() +{ + int x; + + x = 0; + if ((x = x + 2) != 2) // 2 + return 1; + if ((x = x - 1) != 1) // 1 + return 1; + if ((x = x * 6) != 6) // 6 + return 1; + if ((x = x / 2) != 3) // 3 + return 1; + if ((x = x % 2) != 1) // 1 + return 1; + if ((x = x << 2) != 4) // 4 + return 1; + if ((x = x >> 1) != 2) // 2 + return 1; + if ((x = x | 255) != 255) // 255 + return 1; + if ((x = x & 3) != 3) // 3 + return 1; + if ((x = x ^ 1) != 2) // 2 + return 1; + if ((x = x + (x > 1)) != 2) // 2 + return 1; + if ((x = x + (x < 3)) != 2) // 2 + return 1; + if ((x = x + (x > 1)) != 3) // 3 + return 1; + if ((x = x + (x < 4)) != 4) // 4 + return 1; + return 0; +} diff --git a/tests/execute/0135-unary.c b/tests/execute/0135-unary.c @@ -0,0 +1,14 @@ +int +main() +{ + int x; + + x = 3; + x = !x; // 0 + x = !x; // 1 + x = ~x; // -1 + x = -x; // 2 + if(x != 2) + return 1; + return 0; +} diff --git a/tests/execute/0136-if.c b/tests/execute/0136-if.c @@ -0,0 +1,21 @@ +int c; + +int +main() +{ + if(0) { + return 1; + } else if(0) { + /* empty */ + } else { + if(1) { + if(c) + return 1; + else + return 0; + } else { + return 1; + } + } + return 1; +} diff --git a/tests/execute/0137-int-cast.c b/tests/execute/0137-int-cast.c @@ -0,0 +1,275 @@ +/* See LICENSE file for copyright and license details. */ + +/* +name: TEST013 +description: Basic test of integer types and integer conversions +comments: This test depends of the configuration in the type system. + With the current configuration char is equal to unsigned char, + short is equal to int, and unsigned short is equal to unsigned. +error: +output: +G1 I "a +G2 N "b +G3 K "c +G4 C "d +G5 K "e +G6 W "f +G7 Z "g +G8 Q "h +G9 O "i +G10 I "j +G11 N "k +G13 I F "main +{ +\ + G1 G2 gI :I + G1 G3 gI :I + G1 G4 gI :I + G1 G5 gI :I + G1 G6 gI :I + G1 G7 gI :I + G1 G8 gI :I + G1 G9 gI :I + G1 G10 :I + G1 G11 gI :I + G2 G1 gN :N + G2 G3 gN :N + G2 G4 gN :N + G2 G5 gN :N + G2 G6 gN :N + G2 G7 gN :N + G2 G8 gN :N + G2 G9 gN :N + G2 G10 gN :N + G2 G11 :N + G3 G1 gK :K + G3 G2 gK :K + G3 G4 gK :K + G3 G5 :K + G3 G6 gK :K + G3 G7 gK :K + G3 G8 gK :K + G3 G9 gK :K + G3 G10 gK :K + G3 G11 gK :K + G4 G1 gC :C + G4 G2 gC :C + G4 G3 gC :C + G4 G5 gC :C + G4 G6 gC :C + G4 G7 gC :C + G4 G8 gC :C + G4 G9 gC :C + G4 G10 gC :C + G4 G11 gC :C + G5 G1 gK :K + G5 G2 gK :K + G5 G3 :K + G5 G4 gK :K + G5 G6 gK :K + G5 G7 gK :K + G5 G8 gK :K + G5 G9 gK :K + G5 G10 gK :K + G5 G11 gK :K + G6 G1 gW :W + G6 G2 gW :W + G6 G3 gW :W + G6 G4 gW :W + G6 G5 gW :W + G6 G7 gW :W + G6 G8 gW :W + G6 G9 gW :W + G6 G10 gW :W + G6 G11 gW :W + G7 G1 gZ :Z + G7 G2 gZ :Z + G7 G3 gZ :Z + G7 G4 gZ :Z + G7 G5 gZ :Z + G7 G6 gZ :Z + G7 G8 gZ :Z + G7 G9 gZ :Z + G7 G10 gZ :Z + G7 G11 gZ :Z + G8 G1 gQ :Q + G8 G2 gQ :Q + G8 G3 gQ :Q + G8 G4 gQ :Q + G8 G5 gQ :Q + G8 G6 gQ :Q + G8 G7 gQ :Q + G8 G9 gQ :Q + G8 G10 gQ :Q + G8 G11 gQ :Q + G9 G1 gO :O + G9 G2 gO :O + G9 G3 gO :O + G9 G4 gO :O + G9 G5 gO :O + G9 G6 gO :O + G9 G7 gO :O + G9 G8 gO :O + G9 G10 gO :O + G9 G11 gO :O + G10 G1 :I + G10 G2 gI :I + G10 G3 gI :I + G10 G4 gI :I + G10 G5 gI :I + G10 G6 gI :I + G10 G7 gI :I + G10 G8 gI :I + G10 G9 gI :I + G10 G11 gI :I + G11 G1 gN :N + G11 G2 :N + G11 G3 gN :N + G11 G4 gN :N + G11 G5 gN :N + G11 G6 gN :N + G11 G7 gN :N + G11 G8 gN :N + G11 G10 gN :N + G11 G9 gN :N +} +*/ + +int a; +unsigned b; +char c; +signed char d; +unsigned char e; +long f; +unsigned long g; +long long h; +unsigned long long i; +short j; +unsigned short k; + +int +main(void) +{ + a = b; + a = c; + a = d; + a = e; + a = f; + a = g; + a = h; + a = i; + a = j; + a = k; + + b = a; + b = c; + b = d; + b = e; + b = f; + b = g; + b = h; + b = i; + b = j; + b = k; + + c = a; + c = b; + c = d; + c = e; + c = f; + c = g; + c = h; + c = i; + c = j; + c = k; + + d = a; + d = b; + d = c; + d = e; + d = f; + d = g; + d = h; + d = i; + d = j; + d = k; + + e = a; + e = b; + e = c; + e = d; + e = f; + e = g; + e = h; + e = i; + e = j; + e = k; + + f = a; + f = b; + f = c; + f = d; + f = e; + f = g; + f = h; + f = i; + f = j; + f = k; + + g = a; + g = b; + g = c; + g = d; + g = e; + g = f; + g = h; + g = i; + g = j; + g = k; + + h = a; + h = b; + h = c; + h = d; + h = e; + h = f; + h = g; + h = i; + h = j; + h = k; + + i = a; + i = b; + i = c; + i = d; + i = e; + i = f; + i = g; + i = h; + i = j; + i = k; + + j = a; + j = b; + j = c; + j = d; + j = e; + j = f; + j = g; + j = h; + j = i; + j = k; + + k = a; + k = b; + k = c; + k = d; + k = e; + k = f; + k = g; + k = h; + k = j; + k = i; + + return 0; +} diff --git a/tests/execute/0138-namespace.c b/tests/execute/0138-namespace.c @@ -0,0 +1,30 @@ +typedef struct s s; + +struct s { + struct s1 { + int s; + struct s2 { + int s; + } s1; + } s; +} s2; + +#define s s + +int +main(void) +{ +#undef s + goto s; + struct s s; + { + int s; + return s; + } + return s.s.s + s.s.s1.s; + s: + { + return 0; + } + return 1; +} diff --git a/tests/execute/0139-ptr-ary.c b/tests/execute/0139-ptr-ary.c @@ -0,0 +1,22 @@ +int +main() +{ + char arr[2][4], (*p)[4], *q; + int v[4]; + + p = arr; + q = &arr[1][3]; + arr[1][3] = 2; + v[0] = 2; + + if (arr[1][3] != 2) + return 1; + if (p[1][3] != 2) + return 1; + if (*q != 2) + return 1; + if (*v != 2) + return 1; + + return 0; +} diff --git a/tests/execute/0140-int-fold.c b/tests/execute/0140-int-fold.c @@ -0,0 +1,27 @@ +int +main(void) +{ + int i; + + i = 1 + 2; + i = 2 - 1; + i = 3 * 6; + i = 10 / 5; + i = 10 % 5; + i = i % 0; + i = i % 0; + i = 1 << 3; + i = 8 >> 2; + i = 12 & 4; + i = 8 | 4; + i = 12 ^ 4; + i = -(3); + i = ~12; + i = 1 < 3; + i = 2 > 3; + i = 2 >= 3; + i = 2 <= 3; + i = 1 == 0; + + return 0; +} diff --git a/tests/execute/0141-int-iden.c b/tests/execute/0141-int-iden.c @@ -0,0 +1,37 @@ +int +main(void) +{ + int i; + + i = i || 0; + i = i || 4; + i = 4 || i; + i = 0 || i; + i = i && 0; + i = i && 4; + i = 4 && i; + i = 0 && i; + i = i << 0; + i = 0 << i; + i = i >> 0; + i = 0 >> i; + i = i + 0; + i = 0 + i; + i = i - 0; + i = 0 - i; + i = i | 0; + i = 0 | i; + i = i ^ 0; + i = 0 ^ i; + i = i * 0; + i = 0 * i; + i = i * 1; + i = 1 * i; + i = i / 1; + i = 1 / i; + i = i & ~0; + i = ~0 & i; + i = i % 1; + i = i / 0; + i = i % 0; +} diff --git a/tests/execute/0142-char-const.c b/tests/execute/0142-char-const.c @@ -0,0 +1,41 @@ + +int +main(void) +{ + unsigned char uc; + signed char sc; + + uc = -1; + if ((uc & 0xFF) != 0xFF) + return 1; + + uc = '\x23'; + if (uc != 36) + return 1; + + uc = 1u; + if (uc != (1025 & 0xFF) + return 1; + + uc = 'A'; + if (uc != 0x41) + return 1; + + sc = -1; + if ((sc & 0xFF) != 0xFF) + return 1; + + sc = '\x23'; + if (sc != 36) + return 1; + + sc = 1u; + if (uc != (1025 & 0xFF) + return 1; + + sc = 'A'; + if (uc != 0x41) + return 1; + + return 0; +} diff --git a/tests/execute/0143-int-const.c b/tests/execute/0143-int-const.c @@ -0,0 +1,24 @@ +main(void) +{ + int i; + unsigned u; + + i = 1; + i = -1; + i = -1l; + i = -1u; + i = -1ll; + i = 32766 + 1 & 3; + i = (int) 32768 < 0; + i = -1u < 0; + + u = 1; + u = -1; + u = -1l; + u = -1u; + u = -1ll; + u = (unsigned) 32768 < 0; + u = 32766 + 1 & 3; + u = -1u < 0; + return 0; +} diff --git a/tests/execute/0144-long-const.c b/tests/execute/0144-long-const.c @@ -0,0 +1,25 @@ +int +main(void) +{ + long i; + unsigned long u; + + i = 1; + i = -1; + i = -1l; + i = -1u; + i = -1ll; + i = (1ll << 32) - 1 & 3; + i = (long) ((1ll << 32) - 1) < 0; + i = -1u < 0; + + u = 1; + u = -1; + u = -1l; + u = -1u; + u = -1ll; + u = (1ll << 32) - 1 & 3; + u = (long) ((1ll << 32) - 1) < 0; + u = -1u < 0; + return 0; +} diff --git a/tests/execute/0145-llong-const.c b/tests/execute/0145-llong-const.c @@ -0,0 +1,23 @@ +int +main(void) +{ + long long i; + unsigned long long u; + + i = 1; + i = -1; + i = -1l; + i = -1u; + i = -1ll; + i = -1ll & 3; + i = -1ll < 0; + + u = 1; + u = -1; + u = -1l; + u = -1u; + u = -1ll; + u = -1llu & 3; + u = -1llu < 0; + return 0; +} diff --git a/tests/execute/0146-ifdef.c b/tests/execute/0146-ifdef.c @@ -0,0 +1,52 @@ +#define FOO + +#ifdef FOO + int a; + int b; + #undef FOO + #ifndef FOO + int c; + int d; + #else + int e; + int f; + #endif + int e; + int f; + #ifdef FOO + int c_; + int d_; + #else + int e_; + int f_; + #endif + int e_; + int f_; +int +main() +{ + return 0; +} +#else + int j; + int k; + #ifdef FOO + int j; + int k; + #else + int n; + int o; + #endif + int n; + int o; + #ifndef FOO + int r; + int s; + #else + int t; + int u; + #endif + int t; + int u; + #error bad branch +#endif diff --git a/tests/execute/0147-intern-cpp.c b/tests/execute/0147-intern-cpp.c @@ -0,0 +1,19 @@ +#define x(y) (y) + +int +main(void) +{ + int y; + char *p; + + p = __FILE__; + y = __LINE__; + p = __DATE__; + y = __STDC__; + p = __TIME__; + y = __STDC_HOSTED__; + y = __SCC__; + y = x(1); + + return 0; +} diff --git a/tests/execute/0148-cpp-string.c b/tests/execute/0148-cpp-string.c @@ -0,0 +1,10 @@ +#define x(y) #y + +int +main(void) +{ + char *p; + p = x(hello) " is better than bye"; + + return (*p == 'h') ? 0 : 1; +} diff --git a/tests/execute/0149-define.c b/tests/execute/0149-define.c @@ -0,0 +1,10 @@ +#define M(x) x +#define A(a,b) a(b) + +int +main(void) +{ + char *a = A(M,"hi"); + + return (a[1] == 'i') ? 0 : 1; +} diff --git a/tests/execute/0150-define.c b/tests/execute/0150-define.c @@ -0,0 +1,15 @@ +/* + * f(2) will expand to 2*g, which will expand to 2*f, and in this + * moment f will not be expanded because the macro definition is + * a function alike macro, and in this case there is no arguments. + */ +#define f(a) a*g +#define g f + +int +main(void) +{ + int f = 0; + + return f(2); +} diff --git a/tests/execute/0151-vararg.c b/tests/execute/0151-vararg.c @@ -0,0 +1,25 @@ +struct foo { + int i, j, k; + char *p; + float v; +}; + +int +f1(struct foo f, struct foo *p, int n, ...) +{ + if (f.i != p->i) + return 0; + return p->j + n; +} + +int +main(void) +{ + struct foo f; + + f.i = f.j = 1; + f1(f, &f, 2); + f1(f, &f, 2, 1, f, &f); + + return 0; +} diff --git a/tests/execute/0152-cat.c b/tests/execute/0152-cat.c @@ -0,0 +1,14 @@ +#define CAT(x,y) x ## y +#define XCAT(x,y) CAT(x,y) +#define FOO foo +#define BAR bar + +int +main(void) +{ + int foo, bar, foobar; + + CAT(foo,bar) = foo + bar; + XCAT(FOO,BAR) = foo + bar; + return 0; +} diff --git a/tests/execute/0153-cpp-string.c b/tests/execute/0153-cpp-string.c @@ -0,0 +1,13 @@ +#define M1(x) "This is a string $ or # or ## " ## #x +#define STR "This is a string $ or # or ## and it is ok!" + +int +main(void) +{ + char *s, *t = M1(and it is ok!); + + for (s = STR; *s && *s == *t; ++s) + ++t; + + return *s; +} diff --git a/tests/execute/0154-if-defined b/tests/execute/0154-if-defined @@ -0,0 +1,15 @@ +#if defined(FOO) +int a; +#elif !defined(FOO) && defined(BAR) +int b; +#elif !defined(FOO) && !defined(BAR) +int c; +#else +int d; +#endif + +int +main(void) +{ + return c; +} diff --git a/tests/execute/0155-struct-compl.c b/tests/execute/0155-struct-compl.c @@ -0,0 +1,16 @@ +extern struct X x; +int foo(); + +int main() +{ + extern struct X x; + return &x != 0; +} + +struct X {int v;}; + +int foo() +{ + x.v = 0; + return x.v; +} diff --git a/tests/execute/0156-duff2.c b/tests/execute/0156-duff2.c @@ -0,0 +1,35 @@ +/* + * Disgusting, no? But it compiles and runs just fine. I feel a + * combination of pride and revulsion at this discovery. If no one's + * thought of it before, I think I'll name it after myself. It amazes + * me that after 10 years of writing C there are still little corners + * that I haven't explored fully. + * - Tom Duff + */ +send(to, from, count) + register short *to, *from; + register count; +{ + register n=(count+7)/8; + switch(count%8){ + case 0: do{*to = *from++; + case 7: *to = *from++; + case 6: *to = *from++; + case 5: *to = *from++; + case 4: *to = *from++; + case 3: *to = *from++; + case 2: *to = *from++; + case 1: *to = *from++; + }while(--n>0); + } +} + +int +main() +{ + short a, b[40]; + + send(&a, b, 40); + + return (a == b[39]) ? 0 : 1; +} diff --git a/tests/execute/0157-list.c b/tests/execute/0157-list.c @@ -0,0 +1,14 @@ +typedef struct List List; +struct List { + int len; + struct List *head; + List *back; +}; + +int +main(void) +{ + List List; + + return List.len; +} diff --git a/tests/execute/0158-ternary.c b/tests/execute/0158-ternary.c @@ -0,0 +1,17 @@ +int +main(void) +{ + int i, *q; + void *p; + + i = i ? 0 : 0l; + p = i ? (void *) 0 : 0; + p = i ? 0 : (void *) 0; + p = i ? 0 : (const void *) 0; + q = i ? 0 : p; + q = i ? p : 0; + q = i ? q : 0; + q = i ? 0 : q; + + return (int) q; +} diff --git a/tests/execute/0159-typedef.c b/tests/execute/0159-typedef.c @@ -0,0 +1,24 @@ +/* Taken from plan9 kernel */ + +typedef struct Clock0link Clock0link; +typedef struct Clock0link { + int (*clock)(void); + Clock0link* link; +} Clock0link; + + +int +f(void) +{ + return 0; +} + +Clock0link cl0 = { + .clock = f; +}; + +int +main(void) +{ + return (*cl0.clock)(); +} diff --git a/tests/execute/0160-cpp-if.c b/tests/execute/0160-cpp-if.c @@ -0,0 +1,17 @@ +#if 0 != (0 && (0/0)) + #error 0 != (0 && (0/0)) +#endif + +#if 1 != (-1 || (0/0)) + #error 1 != (-1 || (0/0)) +#endif + +#if 3 != (-1 ? 3 : (0/0)) + #error 3 != (-1 ? 3 : (0/0)) +#endif + +int +main() +{ + return 0; +} diff --git a/tests/execute/0161-struct.c b/tests/execute/0161-struct.c @@ -0,0 +1,12 @@ +struct S { int a; int b; }; +struct S s = (struct S){1, 2}; + +int +main() +{ + if(s.a != 1) + return 1; + if(s.b != 2) + return 2; + return 0; +} diff --git a/tests/execute/0162-array.c b/tests/execute/0162-array.c @@ -0,0 +1,13 @@ +int arr[3] = {[2] = 2, [0] = 0, [1] = 1}; + +int +main() +{ + if(arr[0] != 0) + return 1; + if(arr[1] != 1) + return 2; + if(arr[2] != 2) + return 3; + return 0; +} diff --git a/tests/execute/0163-array.c b/tests/execute/0163-array.c @@ -0,0 +1,16 @@ +struct S {int a; int b;}; +struct S arr[2] = {[1] = {3, 4}, [0] = {1, 2}}; + +int +main() +{ + if(arr[0].a != 1) + return 1; + if(arr[0].b != 2) + return 2; + if(arr[1].a != 3) + return 3; + if(arr[1].b != 4) + return 4; + return 0; +} diff --git a/tests/execute/0164-struct.c b/tests/execute/0164-struct.c @@ -0,0 +1,12 @@ +struct S { int a; int b; }; +struct S *s = &(struct S) { 1, 2 }; + +int +main() +{ + if(s->a != 1) + return 1; + if(s->b != 2) + return 2; + return 0; +} diff --git a/tests/execute/0165-struct.c b/tests/execute/0165-struct.c @@ -0,0 +1,33 @@ +struct S1 { + int a; + int b; +}; +struct S2 { + struct S1 s1; + struct S1 *ps1; + int arr[2]; +}; +struct S1 gs1 = (struct S1) {.a = 1, 2}; +struct S2 *s = &(struct S2) { + {.b = 2, .a = 1}, + &gs1, + {[0] = 1, 1+1} +}; + +int +main() +{ + if(s->s1.a != 1) + return 1; + if(s->s1.b != 2) + return 2; + if(s->ps1->a != 1) + return 3; + if(s->ps1->b != 2) + return 4; + if(s->arr[0] != 1) + return 5; + if(s->arr[1] != 2) + return 6; + return 0; +} diff --git a/tests/execute/0166-desig.c b/tests/execute/0166-desig.c @@ -0,0 +1,18 @@ +struct S { + int a, b, c; + char d[3]; + int e; +} s = { + .a = 1, + .b = 2, + .d = {[0] = 3, [2] = 5}, + .d = {[0] = 4, [1] = 6} +}; + +char m[] = {}; + +int +main(void) +{ + return sizeof(m) == s.d[2]; +} diff --git a/tests/execute/0167-array.c b/tests/execute/0167-array.c @@ -0,0 +1,15 @@ +int arr1[][3] = { + { 2, 7, 5, }, + { 5, 1, 2, }, +}; + +int arr2[2][3] = { + 2, 7, 5, + 5, 1, 2 +}; + +int +main(void) +{ + return !(arr1[1][2] == arr2[1][3]); +} diff --git a/tests/execute/0168-array.c b/tests/execute/0168-array.c @@ -0,0 +1,16 @@ +int arr[][3][5] = { + { + { 0, 0, 3, 5 }, + { 1, [3] = 6, 7 }, + }, + { + { 1, 2 }, + { [4] = 7, }, + }, +}; + +int +main(void) +{ + return !(arr[0][1][4] == arr[1][1][4]); +} diff --git a/tests/execute/0169-string.c b/tests/execute/0169-string.c @@ -0,0 +1,27 @@ +char s0[] = "foo"; +char s1[7] = "foo"; +char s2[2] = "foo"; +char s3[] = {"foo"}; +char *p = "foo"; + +int +cmp(char *s1, char *s2) +{ + while (*s1 && *s1++ != *s2++) + ; + return *s1; +} + +int +main() +{ + if (sizeof(s0) != 4 || cmp(s0, "foo")) + return 1; + if (cmp(s1, "foo")) + return 1; + if (s2[0] != 'f' || s2[1] != 'o') + return 1; + if (sizeof(s3) != 4 || cmp(s3, "foo")) + return 1; + return 0; +} diff --git a/tests/execute/0170-line.c b/tests/execute/0170-line.c @@ -0,0 +1,13 @@ +#undef line +#define line 1000 + +#line line +#if 1000 != __LINE__ + #error " # line line" not work as expected +#endif + +int +main() +{ + return 0; +} diff --git a/tests/execute/0171-macros.c b/tests/execute/0171-macros.c @@ -0,0 +1,10 @@ +#define X (2) +#define L (0) +#define H (1) +#define Q(x) x + +int +main(void) +{ + return X == L + H + Q(1); +} diff --git a/tests/execute/0172-hexa.c b/tests/execute/0172-hexa.c @@ -0,0 +1,10 @@ +int +main(void) +{ + return 0xa == 0xA && + 0xb == 0xB && + 0xc == 0xC && + 0xd == 0xD && + 0xe == 0xE && + 0xf == 0xF; +} diff --git a/tests/execute/0173-macro.c b/tests/execute/0173-macro.c @@ -0,0 +1,13 @@ +#define x f +#define y() f + +typedef struct { int f; } S; + +int +main() +{ + S s; + + s.x = 0; + return s.y(); +} diff --git a/tests/execute/0174-decay.c b/tests/execute/0174-decay.c @@ -0,0 +1,24 @@ +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 1; +} diff --git a/tests/execute/0175-defined.c b/tests/execute/0175-defined.c @@ -0,0 +1,32 @@ +#if defined X +X +#endif + +#if defined(X) +X +#endif + +#if X +X +#endif + +#define X 0 + +#if X +X +#endif + +#if defined(X) +int x = 0; +#endif + +#undef X +#define X 1 + +#if X +int +main() +{ + return 0; +} +#endif diff --git a/tests/execute/scc-tests.lst b/tests/execute/scc-tests.lst @@ -121,3 +121,48 @@ 0128-kr_names.c 0129-initi.c [TODO] 0130-mulpars.c +0131-hello.c [TODO] +0132-forward.c [TODO] +0133-ftn-ptr.c [TODO] +0134-arith.c [TODO] +0135-unary.c [TODO] +0136-if.c [TODO] +0137-int-cast.c [TODO] +0138-namespace.c [TODO] +0139-ptr-ary.c [TODO] +0140-int-fold.c [TODO] +0141-int-iden.c [TODO] +0142-char-const.c [TODO] +0143-int-const.c [TODO] +0144-long-const.c [TODO] +0145-llong-const.c [TODO] +0146-ifdef.c [TODO] +0147-intern-cpp.c [TODO] +0148-cpp-string.c [TODO] +0149-define.c [TODO] +0150-define.c [TODO] +0151-vararg.c [TODO] +0152-cat.c [TODO] +0153-cpp-string.c [TODO] +0154-if-defined [TODO] +0155-struct-compl.c [TODO] +0156-duff2.c [TODO] +0157-list.c [TODO] +0158-ternary.c [TODO] +0159-typedef.c [TODO] +0160-cpp-if.c [TODO] +0161-struct.c [TODO] +0162-array.c [TODO] +0163-array.c [TODO] +0164-struct.c [TODO] +0165-struct.c [TODO] +0166-desig.c [TODO] +0167-array.c [TODO] +0168-array.c [TODO] +0169-string.c [TODO] +0170-line.c [TODO] +0171-macros.c [TODO] +0172-hexa.c [TODO] +0173-macro.c [TODO] +0174-decay.c [TODO] +0175-defined.c [TODO]