From: cuz Date: Fri, 17 Feb 2006 20:19:35 +0000 (+0000) Subject: Parse the C99 "restrict" keyword correctly (but ignore it otherwise). X-Git-Tag: V2.12.0~148 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=64921852dd4941505f6a2c1bd47a4da1f462f220;p=cc65 Parse the C99 "restrict" keyword correctly (but ignore it otherwise). git-svn-id: svn://svn.cc65.org/cc65/trunk@3706 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- diff --git a/src/cc65/datatype.h b/src/cc65/datatype.h index 284506aa8..39e7338ab 100644 --- a/src/cc65/datatype.h +++ b/src/cc65/datatype.h @@ -104,7 +104,8 @@ enum { T_QUAL_NONE = 0x0000, T_QUAL_CONST = 0x1000, T_QUAL_VOLATILE = 0x2000, - T_MASK_QUAL = 0x3000, + T_QUAL_RESTRICT = 0x4000, + T_MASK_QUAL = 0x7000, /* Types */ T_CHAR = T_TYPE_CHAR | T_CLASS_INT | T_SIGN_UNSIGNED | T_SIZE_NONE, diff --git a/src/cc65/declare.c b/src/cc65/declare.c index e874f8046..4eedad6da 100644 --- a/src/cc65/declare.c +++ b/src/cc65/declare.c @@ -103,6 +103,13 @@ static type OptionalQualifiers (type Q) Q |= T_QUAL_VOLATILE; break; + case TOK_RESTRICT: + if (Q & T_QUAL_RESTRICT) { + Error ("Duplicate qualifier: `restrict'"); + } + Q |= T_QUAL_RESTRICT; + break; + default: Internal ("Unexpected type qualifier token: %d", CurTok.Tok); diff --git a/src/cc65/expr.c b/src/cc65/expr.c index 8c1218a2b..08f42baa1 100644 --- a/src/cc65/expr.c +++ b/src/cc65/expr.c @@ -639,7 +639,7 @@ static void Primary (ExprDesc* E) Error ("Preprocessor expression expected"); ED_MakeConstAbsInt (E, 1); return; - } + } switch (CurTok.Tok) { @@ -1628,6 +1628,8 @@ static void hie_internal (const GenDesc* Ops, /* List of generators */ /* All operators that call this function expect an int on the lhs */ if (!IsClassInt (Expr->Type)) { Error ("Integer expression expected"); + /* To avoid further errors, make Expr a valid int expression */ + ED_MakeConstAbsInt (Expr, 1); } /* Remember the operator token, then skip it */ diff --git a/src/cc65/scanner.h b/src/cc65/scanner.h index db297ff01..b35c5654a 100644 --- a/src/cc65/scanner.h +++ b/src/cc65/scanner.h @@ -58,7 +58,6 @@ typedef enum token_t { TOK_AUTO, TOK_EXTERN, TOK_REGISTER, - TOK_RESTRICT, TOK_STATIC, TOK_TYPEDEF, @@ -66,7 +65,8 @@ typedef enum token_t { TOK_FIRST_TYPEQUAL, TOK_CONST = TOK_FIRST_TYPEQUAL, TOK_VOLATILE, - TOK_LAST_TYPEQUAL = TOK_VOLATILE, + TOK_RESTRICT, + TOK_LAST_TYPEQUAL = TOK_RESTRICT, /* Tokens denoting types */ TOK_FIRST_TYPE,