[hackers] [scc] Basic test for character constants || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Mon, 7 Sep 2015 19:19:50 +0200 (CEST)

commit ba2ad29b2bf580b5b6318289488b1b18bfd81cc4
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Mon Sep 7 19:01:59 2015 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Mon Sep 7 19:18:15 2015 +0200

    Basic test for character constants

diff --git a/cc1/lex.c b/cc1/lex.c
index 1344c32..a0750c4 100644
--- a/cc1/lex.c
+++ b/cc1/lex.c
_AT_@ -351,7 +351,7 @@ escape(void)
                 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;
_AT_@ -365,9 +365,12 @@ character(void)
 
         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;
diff --git a/cc1/tests/test021.c b/cc1/tests/test021.c
new file mode 100644
index 0000000..e9187a0
--- /dev/null
+++ b/cc1/tests/test021.c
_AT_@ -0,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';
+}
Received on Mon Sep 07 2015 - 19:19:50 CEST

This archive was generated by hypermail 2.3.0 : Mon Sep 07 2015 - 19:24:10 CEST