Skip to content

Commit b971a19

Browse files
committed
__pragma: Warn on extra characters after "unused", "unread", "unwritten", "nodestruct" and "naked"
1 parent 1018c36 commit b971a19

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

source/compiler/sc1.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8157,7 +8157,6 @@ static void dopragma(void)
81578157
int tok;
81588158
int bck_litidx,bck_packstr;
81598159
int i;
8160-
int hasparams;
81618160
cell val;
81628161
char *str;
81638162

@@ -8222,11 +8221,13 @@ static void dopragma(void)
82228221

82238222
/* split the option name from parameters */
82248223
str=(char*)&litq[val];
8225-
for (i=0; str[i]!='\0' && str[i]!=' '; i++) {}
8226-
hasparams=(str[i]!='\0');
8227-
str[i]='\0';
8228-
if (hasparams)
8229-
while (str[++i]==' ') {}
8224+
for (i=0; str[i]!='\0' && str[i]!=' '; i++)
8225+
/* nothing */;
8226+
if (str[i]!='\0') {
8227+
str[i]='\0';
8228+
while (str[++i]==' ')
8229+
/* nothing */;
8230+
} /* if */
82308231

82318232
/* check the option name, set the corresponding attribute flag
82328233
* and parse the argument(s), if needed */
@@ -8238,15 +8239,21 @@ static void dopragma(void)
82388239
pc_attributes |= (1U << attrDEPRECATED);
82398240
} else if (!strcmp(str,"unused")) {
82408241
pc_attributes |= (1U << attrUNUSED);
8242+
if (str[i]!='\0') goto unknown_pragma;
82418243
} else if (!strcmp(str,"unread")) {
82428244
pc_attributes |= (1U << attrUNREAD);
8245+
if (str[i]!='\0') goto unknown_pragma;
82438246
} else if (!strcmp(str,"unwritten")) {
82448247
pc_attributes |= (1U << attrUNWRITTEN);
8248+
if (str[i]!='\0') goto unknown_pragma;
82458249
} else if (!strcmp(str,"nodestruct")) {
82468250
pc_attributes |= (1U << attrNODESTRUCT);
8251+
if (str[i]!='\0') goto unknown_pragma;
82478252
} else if (!strcmp(str,"naked")) {
82488253
pc_attributes |= (1U << attrNAKED);
8254+
if (str[i]!='\0') goto unknown_pragma;
82498255
} else {
8256+
unknown_pragma:
82508257
error(207); /* unknown #pragma */
82518258
} /* if */
82528259

0 commit comments

Comments
 (0)