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

Fix const being able to be specified for a function argument multiple times #730

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions source/compiler/sc1.c
Original file line number Diff line number Diff line change
Expand Up @@ -4276,6 +4276,8 @@ static int declargs(symbol *sym,int chkshadow)
ident=iREFERENCE;
break;
case tCONST:
if (fconst)
error(42); /* invalid combination of class specifiers */
if (ident!=iVARIABLE || numtags>0 || fpragma)
error(1,sc_tokens[tSYMBOL-tFIRST],sc_tokens[tCONST-tFIRST]);
fconst=TRUE;
Expand Down
6 changes: 6 additions & 0 deletions source/compiler/tests/gh_730_fix_const_arg.meta
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
'test_type': 'output_check',
'errors': """
gh_730_fix_const_arg.pwn(1) : error 042: invalid combination of class specifiers
"""
}
11 changes: 11 additions & 0 deletions source/compiler/tests/gh_730_fix_const_arg.pwn
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Func1(const const a) return a; // error 042: invalid combination of class specifiers
Func2(const a) return a;
Func3(a) return a;

main()
{
Func1(0);
Func2(0);
Func3(0);
}