Skip to content

revert useless error invention #620

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

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions source/compiler/sc5.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@ static char *warnmsg[] = {
/*245*/ "enum increment \"%s %d\" has no effect on zero value (symbol \"%s\")\n",
/*246*/ "multiplication overflow in enum element declaration (symbol \"%s\")\n",
/*247*/ "use of operator \"~\" on a \"bool:\" value always results in \"true\"\n",
/*248*/ "possible misuse of comma operator\n"
/*248*/ "possible misuse of comma operator\n",
/*249*/ "detected %s with no corresponding %s\n"
};

static char *noticemsg[] = {
Expand Down Expand Up @@ -436,12 +437,12 @@ void pc_pushwarnings(void)
*/
void pc_popwarnings(void)
{
void *p;
if (warnstack.next==NULL) {
error(26,"#pragma warning push"); /* no matching "#pragma warning push" */
void *p=warnstack.next;
if (p==NULL) {
error(249,"#pragma warning pop","#pragma warning push"); /* detected #pragma warning pop with no corresponding #pragma warning push */
return; /* nothing to do */
} /* if */
p=warnstack.next;

memmove(&warnstack,p,sizeof(struct s_warnstack));
free(p);
}
Expand All @@ -453,10 +454,11 @@ SC_FUNC void warnstack_init(void)

SC_FUNC void warnstack_cleanup(void)
{
struct s_warnstack *cur,*next;
if (warnstack.next!=NULL)
struct s_warnstack *cur=warnstack.next,*next;
if (cur!=NULL)
error(1,"#pragma warning pop","-end of file-");
for (cur=warnstack.next; cur!=NULL; cur=next) {

for (;cur!=NULL; cur=next) {
next=cur->next;
free(cur);
} /* for */
Expand Down
2 changes: 1 addition & 1 deletion source/compiler/tests/pragma_warning_3.meta
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
'test_type': 'output_check',
'errors': """
pragma_warning_3.pwn(1) : error 026: no matching "#pragma warning push"
pragma_warning_3.pwn(1) : warning 249: detected #pragma warning pop with no corresponding #pragma warning push
"""
}
2 changes: 1 addition & 1 deletion source/compiler/tests/pragma_warning_3.pwn
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#pragma warning pop // error 026: no matching "#pragma warning push"
#pragma warning pop // warning 249: detected #pragma warning pop with no corresponding #pragma warning push
main(){}