Skip to content

Commit 24dfcba

Browse files
committed
Implement __pragma("warning")
1 parent c1cb9a3 commit 24dfcba

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

source/compiler/sc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,7 @@ SC_FUNC stkitem popstk(void);
704704
SC_FUNC void clearstk(void);
705705
SC_FUNC int plungequalifiedfile(char *name); /* explicit path included */
706706
SC_FUNC int plungefile(char *name,int try_currentpath,int try_includepaths); /* search through "include" paths */
707+
SC_FUNC int number(cell *val,const unsigned char *curptr);
707708
SC_FUNC void preprocess(void);
708709
SC_FUNC void lexinit(void);
709710
SC_FUNC int lex(cell *lexvalue,char **lexsym);

source/compiler/sc1.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8252,6 +8252,33 @@ static void dopragma(void)
82528252
} else if (!strcmp(str,"naked")) {
82538253
pc_attributes |= (1U << attrNAKED);
82548254
if (str[i]!='\0') goto unknown_pragma;
8255+
} else if (!strcmp(str,"warning")) {
8256+
str += i;
8257+
while (*str==' ') str++;
8258+
for (i=0; str[i]!='\0' && str[i]!=' '; i++)
8259+
/* nothing */;
8260+
if (str[i]!='\0') {
8261+
str[i]='\0';
8262+
while (str[++i]==' ')
8263+
/* nothing */;
8264+
} /* if */
8265+
if (strcmp(str,"enable")==0 || strcmp(str,"disable")==0) {
8266+
int len=number(&val,&str[i]);
8267+
if (len==0)
8268+
goto unknown_pragma;
8269+
pc_enablewarning((int)val,(str[0]=='e') ? warnENABLE : warnDISABLE);
8270+
/* warn if there are extra characters after the warning number */
8271+
for (i += len; str[i]==' '; i++)
8272+
/* nothing */;
8273+
if (str[i]!='\0')
8274+
goto unknown_pragma;
8275+
} else if (strcmp(str,"push")==0 && str[i]=='\0') {
8276+
pc_pushwarnings();
8277+
} else if (strcmp(str,"pop")==0 && str[i]=='\0') {
8278+
pc_popwarnings();
8279+
} else {
8280+
goto unknown_pragma;
8281+
} /* if */
82558282
} else {
82568283
unknown_pragma:
82578284
error(207); /* unknown #pragma */

source/compiler/sc2.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,7 @@ static int ftoi(cell *val,const unsigned char *curptr)
843843
* for at "hier2()" (in fact, it is viewed as an operator, not as a
844844
* sign) and the + is invalid (as in K&R C, and unlike ANSI C).
845845
*/
846-
static int number(cell *val,const unsigned char *curptr)
846+
SC_FUNC int number(cell *val,const unsigned char *curptr)
847847
{
848848
int i;
849849
cell value;

0 commit comments

Comments
 (0)