scc

Simple C99 Compiler
Log | Files | Refs | README | LICENSE

commit 8a1556967443af2e55ef33b3cdab613acbc0ef91
parent 2ce22577d4ef7361895212ed8719c8ff8f36e601
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Sun, 10 Jan 2016 09:44:02 +0100

Add test for preprocessor corner cases

Diffstat:
cc1/tests/test044.c | 31+++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+), 0 deletions(-)

diff --git a/cc1/tests/test044.c b/cc1/tests/test044.c @@ -0,0 +1,31 @@ +/* +name: TEST044 +description: Test of corner cases in #if +output: +test044.c:14: warning: division by 0 +test044.c:18: warning: division by 0 +test044.c:22: warning: division by 0 +test044.c:28: error: parameter of #if is not an integer constant expression +test044.c:29: error: #error 3 != (1,2,3) +*/ + +/* 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 +