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
This commit is contained in:
cuz 2006-02-17 20:19:35 +00:00
parent 32164ea8e5
commit 64921852dd
4 changed files with 14 additions and 4 deletions

View file

@ -104,7 +104,8 @@ enum {
T_QUAL_NONE = 0x0000, T_QUAL_NONE = 0x0000,
T_QUAL_CONST = 0x1000, T_QUAL_CONST = 0x1000,
T_QUAL_VOLATILE = 0x2000, T_QUAL_VOLATILE = 0x2000,
T_MASK_QUAL = 0x3000, T_QUAL_RESTRICT = 0x4000,
T_MASK_QUAL = 0x7000,
/* Types */ /* Types */
T_CHAR = T_TYPE_CHAR | T_CLASS_INT | T_SIGN_UNSIGNED | T_SIZE_NONE, T_CHAR = T_TYPE_CHAR | T_CLASS_INT | T_SIGN_UNSIGNED | T_SIZE_NONE,

View file

@ -103,6 +103,13 @@ static type OptionalQualifiers (type Q)
Q |= T_QUAL_VOLATILE; Q |= T_QUAL_VOLATILE;
break; break;
case TOK_RESTRICT:
if (Q & T_QUAL_RESTRICT) {
Error ("Duplicate qualifier: `restrict'");
}
Q |= T_QUAL_RESTRICT;
break;
default: default:
Internal ("Unexpected type qualifier token: %d", CurTok.Tok); Internal ("Unexpected type qualifier token: %d", CurTok.Tok);

View file

@ -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 */ /* All operators that call this function expect an int on the lhs */
if (!IsClassInt (Expr->Type)) { if (!IsClassInt (Expr->Type)) {
Error ("Integer expression expected"); 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 */ /* Remember the operator token, then skip it */

View file

@ -58,7 +58,6 @@ typedef enum token_t {
TOK_AUTO, TOK_AUTO,
TOK_EXTERN, TOK_EXTERN,
TOK_REGISTER, TOK_REGISTER,
TOK_RESTRICT,
TOK_STATIC, TOK_STATIC,
TOK_TYPEDEF, TOK_TYPEDEF,
@ -66,7 +65,8 @@ typedef enum token_t {
TOK_FIRST_TYPEQUAL, TOK_FIRST_TYPEQUAL,
TOK_CONST = TOK_FIRST_TYPEQUAL, TOK_CONST = TOK_FIRST_TYPEQUAL,
TOK_VOLATILE, TOK_VOLATILE,
TOK_LAST_TYPEQUAL = TOK_VOLATILE, TOK_RESTRICT,
TOK_LAST_TYPEQUAL = TOK_RESTRICT,
/* Tokens denoting types */ /* Tokens denoting types */
TOK_FIRST_TYPE, TOK_FIRST_TYPE,