"Variable has unknown size",
"Unknown identifier: `%s'",
"Duplicate qualifier: `%s'",
- "Assignment to const",
+ "Assignment discards `const' qualifier",
+ "Passing argument %u discards `const' qualifier",
};
* convert the actual argument to the type needed.
*/
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 */
assignadjust (Param->Type, &lval2);
/* If we have a prototype, chars may be pushed as chars */
/* Setup the type flags for the assignment */
flags = Size == 1? CF_FORCECHAR : CF_NONE;
- /* Get the expression into the primary */
+ /* Get the expression into the primary */
if (evalexpr (flags, hie1, &lval) == 0) {
/* Constant expression. Adjust the types */
assignadjust (Decl.Type, &lval);
/* Static data */
if (curtok == TOK_ASSIGN) {
- /* Initialization ahead, switch to data segment */
- g_usedata ();
+ /* Initialization ahead, switch to data segment */
+ if (IsConst (Decl.Type)) {
+ g_userodata ();
+ } else {
+ g_usedata ();
+ }
- /* Define the variable label */
- SymData = GetLabel ();
- g_defloclabel (SymData);
+ /* Define the variable label */
+ SymData = GetLabel ();
+ g_defloclabel (SymData);
- /* Skip the '=' */
- NextToken ();
+ /* Skip the '=' */
+ NextToken ();
- /* Allow initialization of static vars */
- ParseInit (Decl.Type);
+ /* Allow initialization of static vars */
+ ParseInit (Decl.Type);
- /* Mark the variable as referenced */
+ /* Mark the variable as referenced */
SC |= SC_REF;
} else {