Skip to content

Commit 555027f

Browse files
committed
Merge remote-tracking branch 'remotes/Daniel-Cortez/__pragma'
2 parents 54c30d4 + fe65d89 commit 555027f

File tree

3 files changed

+21
-10
lines changed

3 files changed

+21
-10
lines changed

source/compiler/sc1.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5546,6 +5546,11 @@ static void statement(int *lastindent,int allow_decl)
55465546
matchtoken(tSTATIC);
55475547
decl_enum(sLOCAL,FALSE);
55485548
break;
5549+
case t__PRAGMA:
5550+
dopragma();
5551+
needtoken(tTERM);
5552+
pragma_apply(curfunc);
5553+
break;
55495554
case t__EMIT: {
55505555
extern char *sc_tokens[];
55515556
const unsigned char *bck_lptr=lptr-strlen(sc_tokens[tok-tFIRST]);
@@ -8284,7 +8289,7 @@ static void pragma_apply(symbol *sym)
82848289
break;
82858290
case attrNAKED:
82868291
if (sym->ident==iFUNCTN)
8287-
sym->flags=flagNAKED;
8292+
sym->flags |= flagNAKED;
82888293
break;
82898294
default:
82908295
assert(0);

source/compiler/tests/__pragma.meta

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
'errors': """
44
__pragma.pwn(6) : error 001: expected token: "-identifier-", but found "const"
55
__pragma.pwn(10) : error 001: expected token: "-identifier-", but found "__pragma"
6-
__pragma.pwn(31) : warning 234: function is deprecated (symbol "Func") - use OtherFunc() instead
7-
__pragma.pwn(28) : warning 203: symbol is never used: "f"
8-
__pragma.pwn(24) : warning 204: symbol is assigned a value that is never used: "e"
9-
__pragma.pwn(24 -- 37) : warning 203: symbol is never used: "operator~(Tag:)"
6+
__pragma.pwn(36) : warning 234: function is deprecated (symbol "Func") - use OtherFunc() instead
7+
__pragma.pwn(40) : warning 234: function is deprecated (symbol "NakedFunc") - use NakedFunc2() instead
8+
__pragma.pwn(33) : warning 203: symbol is never used: "f"
9+
__pragma.pwn(29) : warning 204: symbol is assigned a value that is never used: "e"
10+
__pragma.pwn(29 -- 42) : warning 203: symbol is never used: "operator~(Tag:)"
1011
"""
1112
}

source/compiler/tests/__pragma.pwn

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,15 @@ stock Func3(__pragma("unread") const arg) {}
99
// "__pragma" can't be used between the tag and the symbol name
1010
stock Func4(Tag: __pragma("unread") arg) {}
1111

12-
__pragma("naked") NakedFunc(__pragma("naked", "unused") arg) {}
13-
1412
operator~(Tag:val[],count) {}
1513

14+
NakedFunc()
15+
{
16+
__pragma("naked", "deprecated - use NakedFunc2() instead");
17+
}
18+
19+
__pragma("naked") NakedFunc2(__pragma("naked", "unused") arg = 0) {}
20+
1621
main()
1722
{
1823
new __pragma("unwritten", "unread") a = 0;
@@ -30,7 +35,7 @@ main()
3035
// warning 234: function is deprecated (symbol "Func") - use OtherFunc() instead
3136
Func(0);
3237

33-
// NakedFunc() is marked as "naked", so there should be no warning about it
34-
// having to return a value
35-
return NakedFunc(0);
38+
// NakedFunc() and NakedFunc2() are marked as "naked", so there should be
39+
// no warnings about them having to return a value.
40+
return NakedFunc(), NakedFunc2();
3641
}

0 commit comments

Comments
 (0)