]> git.sur5r.net Git - cc65/commitdiff
Parse the C99 "restrict" keyword correctly (but ignore it otherwise).
authorcuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Fri, 17 Feb 2006 20:19:35 +0000 (20:19 +0000)
committercuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Fri, 17 Feb 2006 20:19:35 +0000 (20:19 +0000)
git-svn-id: svn://svn.cc65.org/cc65/trunk@3706 b7a2c559-68d2-44c3-8de9-860c34a00d81

src/cc65/datatype.h
src/cc65/declare.c
src/cc65/expr.c
src/cc65/scanner.h

index 284506aa8acabc3a37334c64fba8f47ea19dc39e..39e7338abd422b598cc1e9c060f5d231de27108d 100644 (file)
@@ -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,
index e874f804667ec95872b0d108b2b879f148e0050d..4eedad6da73ddd5d170911735a3a641c591735f2 100644 (file)
@@ -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);
 
index 8c1218a2b3f39dec8e1429b7c4978c2959ea4adc..08f42baa1857bc2e79bb397be7b6dc0757748156 100644 (file)
@@ -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 */
index db297ff0148cb0b481a5aff0ff2726228f36a8f5..b35c5654a7dadcbaec0d93ce0ae0670a3b2a876c 100644 (file)
@@ -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,