| CODE {
$$ = newLink (SPECIFIER) ;
SPEC_SCLS($$) = S_CODE ;
- if (port->mem.code_ro) {
- SPEC_CONST($$) = 1;
- }
}
| EEPROM {
$$ = newLink (SPECIFIER) ;
{
sym_link *ltc = (tree->right ? RTYPE (tree) : LTYPE (tree));
COPYTYPE (TTYPE (tree), TETYPE (tree), ltc);
- if (!tree->initMode && IS_CONSTANT (TTYPE (tree)))
+ if (!tree->initMode && IS_CONSTANT(TETYPE(tree)))
werror (E_CODE_WRITE, tree->opval.op==INC_OP ? "++" : "--");
if (tree->right)
RRVAL (tree) = 1;
TETYPE (tree) = getSpec (TTYPE (tree) = LTYPE (tree));
- if (!tree->initMode && IS_CONSTANT (LTYPE (tree)))
+ if (!tree->initMode && IS_CONSTANT (LETYPE (tree)))
werror (E_CODE_WRITE, "&= or |= or ^= or >>= or <<=");
if (LRVAL (tree))
computeType (LTYPE (tree),
RTYPE (tree)));
- if (!tree->initMode && IS_CONSTANT (LTYPE (tree)))
+ if (!tree->initMode && IS_CONSTANT (LETYPE (tree)))
werror (E_CODE_WRITE, "-=");
if (LRVAL (tree))
computeType (LTYPE (tree),
RTYPE (tree)));
- if (!tree->initMode && IS_CONSTANT (LTYPE (tree)))
+ if (!tree->initMode && IS_CONSTANT (LETYPE (tree)))
werror (E_CODE_WRITE, "+=");
if (LRVAL (tree))
RRVAL (tree) = 1;
LLVAL (tree) = 1;
if (!tree->initMode ) {
- if (IS_CONSTANT (LTYPE (tree)))
+ if ((IS_SPEC(LETYPE(tree)) && IS_CONSTANT (LETYPE (tree))))
werror (E_CODE_WRITE, "=");
}
if (LRVAL (tree))
if (isiCodeEqual (ic, cdp->diCode) &&
isOperandEqual (cdp->sym, IC_RESULT (cdp->diCode)))
{
+ *icp = cdp->diCode;
return 1;
}
isOperandEqual (IC_LEFT (ic), IC_RIGHT (cdp->diCode)) &&
isOperandEqual (IC_RIGHT (ic), IC_LEFT (cdp->diCode)))
{
+ *icp = cdp->diCode;
return 1;
}
val->type = newLink (DECLARATOR);
if (SPEC_SCLS (expr->left->etype) == S_CODE) {
DCL_TYPE (val->type) = CPOINTER;
- DCL_TYPE (val->type) = port->mem.code_ro;
+ DCL_PTR_CONST (val->type) = port->mem.code_ro;
}
else if (SPEC_SCLS (expr->left->etype) == S_XDATA)
DCL_TYPE (val->type) = FPOINTER;
op->isGptr = IS_GENPTR (optype);
+ /* if the pointer was declared as a constant */
+ /* then we cannot allow assignment to the derefed */
+ if (IS_PTR_CONST (optype))
+ SPEC_CONST (retype) = 1;
+
op->isaddr = (IS_PTR (rtype) ||
IS_STRUCT (rtype) ||
IS_INT (rtype) ||
storage class of the type */
if (IS_SPEC (type))
{
+ DCL_PTR_CONST (ptr) = SPEC_CONST (type);
+ DCL_PTR_VOLATILE (ptr) = SPEC_VOLATILE (type);
switch (SPEC_SCLS (type))
{
case S_XDATA:
DCL_TYPE (ptr) = POINTER;
break;
case S_CODE:
+ DCL_PTR_CONST (ptr) = port->mem.code_ro;
DCL_TYPE (ptr) = CPOINTER;
break;
case S_EEPROM:
}
/* if the type is an unknown pointer and has
- a tspec then take the const & volatile
+ a tspec then take the storage class const & volatile
attribute from the tspec & make it those of this
symbol */
-
if (p &&
- IS_DECL (p) &&
- DCL_TYPE (p) == UPOINTER &&
+ !IS_SPEC (p) &&
+ //DCL_TYPE (p) == UPOINTER &&
DCL_TSPEC (p))
{
- // only for declarators
- wassert (IS_DECL(sym->type));
-
if (!IS_SPEC (sym->etype))
{
sym->etype = sym->etype->next = newLink (SPECIFIER);
}
-
SPEC_SCLS (sym->etype) = SPEC_SCLS (DCL_TSPEC (p));
- DCL_PTR_CONST (sym->type) = SPEC_CONST (DCL_TSPEC (p));
- DCL_PTR_VOLATILE (sym->type) = SPEC_VOLATILE (DCL_TSPEC (p));
+ SPEC_CONST (sym->etype) = SPEC_CONST (DCL_TSPEC (p));
+ SPEC_VOLATILE (sym->etype) = SPEC_VOLATILE (DCL_TSPEC (p));
DCL_TSPEC (p) = NULL;
}
mergeSpec (sym_link * dest, sym_link * src, char *name)
{
if (!IS_SPEC(dest) || !IS_SPEC(src)) {
+#if 0
+ werror (E_INTERNAL_ERROR, __FILE__, __LINE__, "cannot merge declarator");
+ exit (1);
+#else
werror (E_SYNTAX_ERROR, yytext);
+ // the show must go on
+ return newIntLink();
+#endif
}
if (SPEC_NOUN(src)) {
/* copy all the specifications */
+ // we really should do:
+#if 0
+ if (SPEC_what(src)) {
+ if (SPEC_what(dest)) {
+ werror(W_DUPLICATE_SPEC, "what");
+ }
+ SPEC_what(dst)|=SPEC_what(src);
+ }
+#endif
+ // but there are more important thing right now
+
SPEC_LONG (dest) |= SPEC_LONG (src);
dest->select.s._short|=src->select.s._short;
SPEC_USIGN (dest) |= SPEC_USIGN (src);