ref: ba2ad29b2bf580b5b6318289488b1b18bfd81cc4
parent: 618d3316287444bf57deb532c9d105f7049335cf
author: Roberto E. Vargas Caballero <[email protected]>
date: Mon Sep 7 15:01:59 EDT 2015
Basic test for character constants
--- a/cc1/lex.c
+++ b/cc1/lex.c
@@ -351,7 +351,7 @@
return ' ';
}
errno = 0;
- c = strtoul(input->p, &input->p, base);
+ c = strtoul(++input->p, &input->p, base);
if (errno || c > 255)
warn("character constant out of range");
return c;
@@ -365,9 +365,12 @@
if ((c = *++input->p) == '\\')
c = escape();
+ else
+ c = *input->p++;
if (*input->p != '\'')
error("invalid character constant");
- ++input->p;
+ else
+ ++input->p;
sym = newsym(NS_IDEN);
sym->u.i = c;
--- /dev/null
+++ b/cc1/tests/test021.c
@@ -1,0 +1,43 @@
+
+/*
+name: TEST021
+description: Basic test for char constants
+comments: This test is done for z80 implementation
+output:
+F1
+G1 F1 main
+{
+-
+A2 M uc
+A3 C sc
+ A2 #MFF :M
+ A2 #M23 :M
+ A2 #M1 :M
+ A2 #M1 :M
+ A2 #M41 :M
+ A3 #CFF :C
+ A3 #C23 :C
+ A3 #C1 :C
+ A3 #C1 :C
+ A3 #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';
+}