ref: d00c0a144ba4565dfc73b8429457aba03faf2264
parent: 2f555ae12510f6214164f4e85f49ea2127d3c935
author: Roberto E. Vargas Caballero <[email protected]>
date: Tue Sep 15 08:25:16 EDT 2015
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).
--- a/cc1/cc1.h
+++ b/cc1/cc1.h
@@ -159,10 +159,9 @@
ISEMITTED = 1024,
ISDEFINED = 2048,
ISSTRING = 4096,
- ISTYPEDEF = 8192
+ ISTYPEDEF = 8192
};
-
/* lexer mode, compiler or preprocessor directive */
enum {
CCMODE,
@@ -171,7 +170,10 @@
/* input tokens */
enum tokens {
- TQUALIFIER = 128,
+ CONST = 1, /* type qualifier tokens are used as flags */
+ RESTRICT = 2,
+ VOLATILE = 4,
+ TQUALIFIER = 128,
TYPE,
IDEN,
SCLASS,
@@ -220,9 +222,6 @@
LONG,
LLONG,
COMPLEX,
- CONST,
- VOLATILE,
- RESTRICT,
TYPEDEF,
EXTERN,
STATIC,
--- a/cc1/decl.c
+++ b/cc1/decl.c
@@ -262,7 +262,7 @@
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;
@@ -275,8 +275,6 @@
p = &cls;
break;
case TQUALIFIER:
- if (qlf && qlf != RESTRICT)
- errorp("invalid type specification");
qlf |= yylval.token;
next();
continue;