]> git.sur5r.net Git - cc65/blobdiff - src/cc65/pragma.c
Create one literal pool per function, so that literal pool data is removed
[cc65] / src / cc65 / pragma.c
index 684d6a416371a5fd344cd73f974dbb021fef6b0f..37ae1bbb140991cbab8a7c3741c3024e533d8f2a 100644 (file)
@@ -84,6 +84,7 @@ typedef enum {
     PRAGMA_STATIC_LOCALS,
     PRAGMA_STATICLOCALS,                                /* obsolete */
     PRAGMA_WARN,
+    PRAGMA_WRITABLE_STRINGS,
     PRAGMA_ZPSYM,
     PRAGMA_COUNT
 } pragma_t;
@@ -93,28 +94,29 @@ static const struct Pragma {
     const char*        Key;            /* Keyword */
     pragma_t           Tok;            /* Token */
 } Pragmas[PRAGMA_COUNT] = {
-    { "bss-name",       PRAGMA_BSS_NAME         },
-    { "bssseg",         PRAGMA_BSSSEG           },      /* obsolete */
-    { "charmap",        PRAGMA_CHARMAP          },
-    { "check-stack",    PRAGMA_CHECK_STACK      },
-    { "checkstack",     PRAGMA_CHECKSTACK      },      /* obsolete */
-    { "code-name",      PRAGMA_CODE_NAME        },
-    { "codeseg",        PRAGMA_CODESEG         },      /* obsolete */
-    { "codesize",       PRAGMA_CODESIZE         },
-    { "data-name",      PRAGMA_DATA_NAME        },
-    { "dataseg",        PRAGMA_DATASEG         },      /* obsolete */
-    { "optimize",       PRAGMA_OPTIMIZE         },
-    { "register-vars",  PRAGMA_REGISTER_VARS    },
-    { "regvaraddr",     PRAGMA_REGVARADDR      },
-    { "regvars",        PRAGMA_REGVARS          },      /* obsolete */
-    { "rodata-name",    PRAGMA_RODATA_NAME      },
-    { "rodataseg",      PRAGMA_RODATASEG       },      /* obsolete */
-    { "signed-chars",   PRAGMA_SIGNED_CHARS     },
-    { "signedchars",    PRAGMA_SIGNEDCHARS     },      /* obsolete */
-    { "static-locals",  PRAGMA_STATIC_LOCALS    },
-    { "staticlocals",   PRAGMA_STATICLOCALS    },      /* obsolete */
-    { "warn",           PRAGMA_WARN             },
-    { "zpsym",          PRAGMA_ZPSYM           },
+    { "bss-name",               PRAGMA_BSS_NAME         },
+    { "bssseg",                 PRAGMA_BSSSEG           },      /* obsolete */
+    { "charmap",                PRAGMA_CHARMAP          },
+    { "check-stack",            PRAGMA_CHECK_STACK      },
+    { "checkstack",             PRAGMA_CHECKSTACK      },      /* obsolete */
+    { "code-name",              PRAGMA_CODE_NAME        },
+    { "codeseg",                PRAGMA_CODESEG         },      /* obsolete */
+    { "codesize",               PRAGMA_CODESIZE         },
+    { "data-name",              PRAGMA_DATA_NAME        },
+    { "dataseg",                PRAGMA_DATASEG         },      /* obsolete */
+    { "optimize",               PRAGMA_OPTIMIZE         },
+    { "register-vars",          PRAGMA_REGISTER_VARS    },
+    { "regvaraddr",             PRAGMA_REGVARADDR      },
+    { "regvars",                PRAGMA_REGVARS          },      /* obsolete */
+    { "rodata-name",            PRAGMA_RODATA_NAME      },
+    { "rodataseg",              PRAGMA_RODATASEG       },      /* obsolete */
+    { "signed-chars",           PRAGMA_SIGNED_CHARS     },
+    { "signedchars",            PRAGMA_SIGNEDCHARS     },      /* obsolete */
+    { "static-locals",          PRAGMA_STATIC_LOCALS    },
+    { "staticlocals",           PRAGMA_STATICLOCALS    },      /* obsolete */
+    { "warn",                   PRAGMA_WARN             },
+    { "writable-strings",       PRAGMA_WRITABLE_STRINGS },
+    { "zpsym",                  PRAGMA_ZPSYM           },
 };
 
 /* Result of ParsePushPop */
@@ -174,7 +176,7 @@ static int GetComma (StrBuf* B)
         Error ("Comma expected");
         return 0;
     }
-    SB_SkipWhite (B);                                   
+    SB_SkipWhite (B);
     return 1;
 }
 
@@ -675,10 +677,11 @@ static void ParsePragma (void)
     /* Do we know this pragma? */
     if (Pragma == PRAGMA_ILLEGAL) {
                /* According to the ANSI standard, we're not allowed to generate errors
-                * for unknown pragmas, however, we're allowed to warn - and we will
-                * do so. Otherwise one typo may give you hours of bug hunting...
+                * for unknown pragmas, but warn about them if enabled (the default).
                 */
-               Warning ("Unknown pragma `%s'", SB_GetConstBuf (&Ident));
+        if (IS_Get (&WarnUnknownPragma)) {
+                   Warning ("Unknown pragma `%s'", SB_GetConstBuf (&Ident));
+        }
                goto ExitPoint;
     }
 
@@ -771,6 +774,10 @@ static void ParsePragma (void)
             WarnPragma (&B);
             break;
 
+        case PRAGMA_WRITABLE_STRINGS:
+            FlagPragma (&B, &WritableStrings);
+            break;
+
        case PRAGMA_ZPSYM:
            StringPragma (&B, MakeZPSym);
            break;