shithub: regress

Download patch

ref: 92a6483fc287984ca6b5c40c480f7d7d0c7b5fc7
parent: 9537bdd2580a9bb6f44b0a6ae6f0b1a71cbd4734
author: Ori Bernstein <[email protected]>
date: Sat Jul 25 01:52:21 EDT 2020

cc: add tests for integer constant types.

diff: cannot open b/cmd/cc//null: file does not exist: 'b/cmd/cc//null'
--- /dev/null
+++ b/cmd/cc/cc.rc
@@ -1,0 +1,5 @@
+#!/bin/rc
+
+if($O^c -w intlit.test.c | grep warning)
+	exit 'fail'
+exit ''
--- /dev/null
+++ b/cmd/cc/intlit.test.c
@@ -1,0 +1,45 @@
+/* integer constant type test
+ * reference: C standard 6.4.4.1
+ * not really compliant lol
+ * ori & Amavect
+ */
+#include <u.h>
+#include <libc.h>
+
+void
+main(void)
+{
+	print("%ullX ", 0xFF66554433221100);  /* uvlong */
+	print("%llX ",  0x0000000180000000);  /* vlong */
+	print("\n");
+	print("%X ",   0x7FFFFFFF);   /* int */
+	print("%uX ",  0x80000000);   /* uint */
+	print("%uX ",  0xFFFFFFFF);   /* uint */
+	print("%llX ", 0x100000000);  /* vlong */
+	print("\n");
+	
+	/* vlong (C standard)
+	 * if it parses as uint, it's technically wrong to the standard
+	 * even though it works just fine
+	 * ideally, - is part of an integer constant,
+	 * but that's just not in the standard.
+	 */
+	print("%lld ", -2147483648);
+	print("%d",  -0x80000000);  /* uint, no warning for int format */
+	
+	print("\n");
+	print("%llX ",  0x7FFFFFFFFFFFFFFF);  /* vlong */
+	print("%ullX ", 0x8000000000000000);  /* uvlong */
+	print("%ullX ", 0xFFFFFFFFFFFFFFFF);  /* uvlong */
+	print("%ullX", ~1ULL);  /* uvlong */
+	print("\n");
+	
+	/* uvlong (C standard)
+	 * C standard specifies an extended integer type
+	 * uvlong is our extended vlong :)
+	 */
+	print("%lld ", -9223372036854775808); /* no warning for vlong format */
+	print("%lld", -0x8000000000000000);   /* uvlong, no warning for vlong format */
+	print("\n");
+	
+}
--- /dev/null
+++ b/cmd/cc/mkfile
@@ -1,0 +1,5 @@
+</$objtype/mkfile
+
+TEST=cc
+
+<../../regress