[hackers] [scc] Make type qualifier flags || Roberto E. Vargas Caballero
commit d00c0a144ba4565dfc73b8429457aba03faf2264
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Tue Sep 15 12:25:16 2015 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Tue Sep 15 12:25:16 2015 +0200
Make type qualifier flags
A declaration can have more of one type qualifier (for example const and
volatile), so, it is very useful if the representation of these tokens
are flags. It is also added idempotent for all the type qualifiers
(restrict to).
diff --git a/cc1/cc1.h b/cc1/cc1.h
index ac615a6..a6d2746 100644
--- a/cc1/cc1.h
+++ b/cc1/cc1.h
_AT_@ -159,10 +159,9 @@ enum {
ISEMITTED = 1024,
ISDEFINED = 2048,
ISSTRING = 4096,
- ISTYPEDEF = 8192
+ ISTYPEDEF = 8192
};
-
/* lexer mode, compiler or preprocessor directive */
enum {
CCMODE,
_AT_@ -171,7 +170,10 @@ enum {
/* input tokens */
enum tokens {
- TQUALIFIER = 128,
+ CONST = 1, /* type qualifier tokens are used as flags */
+ RESTRICT = 2,
+ VOLATILE = 4,
+ TQUALIFIER = 128,
TYPE,
IDEN,
SCLASS,
_AT_@ -220,9 +222,6 @@ enum tokens {
LONG,
LLONG,
COMPLEX,
- CONST,
- VOLATILE,
- RESTRICT,
TYPEDEF,
EXTERN,
STATIC,
diff --git a/cc1/decl.c b/cc1/decl.c
index 4eb1003..9731451 100644
--- a/cc1/decl.c
+++ b/cc1/decl.c
_AT_@ -262,7 +262,7 @@ static Type *
specifier(int *sclass)
{
Type *tp = NULL;
- unsigned spec, qlf, sign, type, cls, size;
+ int spec, qlf, sign, type, cls, size, mask;
spec = qlf = sign = type = cls = size = 0;
_AT_@ -275,8 +275,6 @@ specifier(int *sclass)
p = &cls;
break;
case TQUALIFIER:
- if (qlf && qlf != RESTRICT)
- errorp("invalid type specification");
qlf |= yylval.token;
next();
continue;
Received on Tue Sep 15 2015 - 12:37:11 CEST
This archive was generated by hypermail 2.3.0
: Tue Sep 15 2015 - 12:48:12 CEST