mirror of
https://github.com/cc65/cc65.git
synced 2024-12-23 04:30:10 +00:00
Check for const in function parameters (first level only).
Place local static const data into the RODATA segment. git-svn-id: svn://svn.cc65.org/cc65/trunk@253 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
85417b6d1b
commit
d171b3dac9
@ -152,7 +152,8 @@ static char* ErrMsg [ERR_COUNT-1] = {
|
|||||||
"Variable has unknown size",
|
"Variable has unknown size",
|
||||||
"Unknown identifier: `%s'",
|
"Unknown identifier: `%s'",
|
||||||
"Duplicate qualifier: `%s'",
|
"Duplicate qualifier: `%s'",
|
||||||
"Assignment to const",
|
"Assignment discards `const' qualifier",
|
||||||
|
"Passing argument %u discards `const' qualifier",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -148,6 +148,7 @@ enum Errors {
|
|||||||
ERR_UNKNOWN_IDENT,
|
ERR_UNKNOWN_IDENT,
|
||||||
ERR_DUPLICATE_QUALIFIER,
|
ERR_DUPLICATE_QUALIFIER,
|
||||||
ERR_CONST_ASSIGN,
|
ERR_CONST_ASSIGN,
|
||||||
|
ERR_CONST_PARAM,
|
||||||
ERR_COUNT /* Error count */
|
ERR_COUNT /* Error count */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -580,6 +580,16 @@ static void callfunction (struct expent* lval)
|
|||||||
* convert the actual argument to the type needed.
|
* convert the actual argument to the type needed.
|
||||||
*/
|
*/
|
||||||
if (!Ellipsis) {
|
if (!Ellipsis) {
|
||||||
|
/* If the left side is not const and the right is const, print
|
||||||
|
* an error. Note: This is an incomplete check, since other parts
|
||||||
|
* of the type string may have a const qualifier, but it catches
|
||||||
|
* some errors and is cheap here. We will redo it the right way
|
||||||
|
* as soon as the parser is rewritten. ####
|
||||||
|
*/
|
||||||
|
if (!IsConst (Param->Type) && IsConst (lval2.e_tptr)) {
|
||||||
|
Error (ERR_CONST_PARAM, ParamCount);
|
||||||
|
}
|
||||||
|
|
||||||
/* Promote the argument if needed */
|
/* Promote the argument if needed */
|
||||||
assignadjust (Param->Type, &lval2);
|
assignadjust (Param->Type, &lval2);
|
||||||
/* If we have a prototype, chars may be pushed as chars */
|
/* If we have a prototype, chars may be pushed as chars */
|
||||||
|
@ -269,7 +269,11 @@ static void ParseOneDecl (const DeclSpec* Spec)
|
|||||||
if (curtok == TOK_ASSIGN) {
|
if (curtok == TOK_ASSIGN) {
|
||||||
|
|
||||||
/* Initialization ahead, switch to data segment */
|
/* Initialization ahead, switch to data segment */
|
||||||
|
if (IsConst (Decl.Type)) {
|
||||||
|
g_userodata ();
|
||||||
|
} else {
|
||||||
g_usedata ();
|
g_usedata ();
|
||||||
|
}
|
||||||
|
|
||||||
/* Define the variable label */
|
/* Define the variable label */
|
||||||
SymData = GetLabel ();
|
SymData = GetLabel ();
|
||||||
|
Loading…
Reference in New Issue
Block a user