From eba7d94aaf69f486434eca2f4f321da3c4fc4e3b Mon Sep 17 00:00:00 2001 From: shel <2@shelru.ru> Date: Tue, 24 Nov 2020 09:35:46 +0400 Subject: [PATCH] update sc5.c, tests --- source/compiler/sc5.c | 18 ++++++++++-------- source/compiler/tests/pragma_warning_3.meta | 2 +- source/compiler/tests/pragma_warning_3.pwn | 2 +- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/source/compiler/sc5.c b/source/compiler/sc5.c index 3302cfa7..f644aab7 100644 --- a/source/compiler/sc5.c +++ b/source/compiler/sc5.c @@ -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[] = { @@ -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); } @@ -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 */ diff --git a/source/compiler/tests/pragma_warning_3.meta b/source/compiler/tests/pragma_warning_3.meta index 66c95cd5..776cbe3e 100644 --- a/source/compiler/tests/pragma_warning_3.meta +++ b/source/compiler/tests/pragma_warning_3.meta @@ -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 """ } diff --git a/source/compiler/tests/pragma_warning_3.pwn b/source/compiler/tests/pragma_warning_3.pwn index 27f7b070..441d977b 100644 --- a/source/compiler/tests/pragma_warning_3.pwn +++ b/source/compiler/tests/pragma_warning_3.pwn @@ -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(){}