shithub: regress

ref: 75f5c7d3948bc647b21272c2e0bcbf841fb4d9f7
dir: /cmd/cc/intlit.test.c/

View raw version
/* 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");
	
}