Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add #warning directive #170

Merged
merged 4 commits into from Feb 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions compiler/sc.h
Expand Up @@ -497,6 +497,7 @@ enum TokenKind {
tpENDINPUT,
tpENDSCRPT,
tpERROR,
tpWARNING,
tpFILE,
tpIF, /* #if */
tINCLUDE,
Expand Down
10 changes: 8 additions & 2 deletions compiler/sc2.cpp
Expand Up @@ -1292,6 +1292,12 @@ static int command(void)
if (!SKIPPING)
error(FATAL_ERROR_USER_ERROR,lptr); /* user error */
break;
case tpWARNING:
while (*lptr<=' ' && *lptr!='\0')
lptr++;
if (!SKIPPING)
error(224,lptr); /* user warning */
break;
default:
error(31); /* unknown compiler directive */
ret=SKIPPING ? CMD_CONDFALSE : CMD_NONE; /* process as normal line */
Expand Down Expand Up @@ -1946,8 +1952,8 @@ const char *sc_tokens[] = {
"while",
"with",
"#assert", "#define", "#else", "#elseif", "#endif", "#endinput",
"#endscript", "#error", "#file", "#if", "#include", "#line", "#pragma",
"#tryinclude", "#undef",
"#endscript", "#error", "#warning", "#file", "#if", "#include",
"#line", "#pragma", "#tryinclude", "#undef",
";", ";", "-integer value-", "-rational value-", "-identifier-",
"-label-", "-string-", "-string-"
};
Expand Down
2 changes: 1 addition & 1 deletion compiler/sc5-in.scp
Expand Up @@ -257,7 +257,7 @@ static const char *warnmsg[] = {
/*221*/ "label name \"%s\" shadows tag name\n",
/*222*/ "number of digits exceeds rational number precision\n",
/*223*/ "redundant \"sizeof\": argument size is always 1 (symbol \"%s\")\n",
/*224*/ "unused\n",
/*224*/ "user warning: %s\n",
/*225*/ "unreachable code\n",
/*226*/ "a variable is assigned to itself (symbol \"%s\")\n",
/*227*/ "more initializers than enum fields\n",
Expand Down
6 changes: 6 additions & 0 deletions compiler/tests/warn-user-warning.sp
@@ -0,0 +1,6 @@
#warning test

public void main()
{

}
1 change: 1 addition & 0 deletions compiler/tests/warn-user-warning.txt
@@ -0,0 +1 @@
(1) : warning 224: user warning: test