shithub: scc

Download patch

ref: 8a1556967443af2e55ef33b3cdab613acbc0ef91
parent: 2ce22577d4ef7361895212ed8719c8ff8f36e601
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Sun Jan 10 04:44:02 EST 2016

Add test for preprocessor corner cases

--- /dev/null
+++ b/cc1/tests/test044.c
@@ -1,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
+