SPEC_BLEN (dest) |= SPEC_BLEN (src);
SPEC_BSTR (dest) |= SPEC_BSTR (src);
SPEC_TYPEDEF (dest) |= SPEC_TYPEDEF (src);
+ SPEC_ENUM (dest) |= SPEC_ENUM (src);
if (IS_STRUCT (dest) && SPEC_STRUCT (dest) == NULL)
SPEC_STRUCT (dest) = SPEC_STRUCT (src);
/* this is a specifier */
switch (DCL_TYPE (p))
{
- case FUNCTION:
- return 2;
case ARRAY:
- return DCL_ELEM (p) * getSize (p->next);
+ if (DCL_ELEM(p)) {
+ return DCL_ELEM (p) * getSize (p->next);
+ } else {
+ werror (E_INTERNAL_ERROR, __FILE__, __LINE__,
+ "can not tell the size of an array[]");
+ return 0;
+ }
case IPOINTER:
case PPOINTER:
case POINTER:
case EEPPOINTER:
case FPOINTER:
case CPOINTER:
+ case FUNCTION:
return (FPTRSIZE);
case GPOINTER:
return (GPTRSIZE);
/* this is a specifier */
switch (DCL_TYPE (p))
{
- case FUNCTION:
- return 2;
case ARRAY:
return DCL_ELEM (p) * getSize (p->next) * 8;
case IPOINTER:
case EEPPOINTER:
case FPOINTER:
case CPOINTER:
+ case FUNCTION:
return (FPTRSIZE * 8);
case GPOINTER:
return (GPTRSIZE * 8);
else if (IS_BITVAR (etype2) && !IS_BITVAR (etype1))
rType = copyLinkChain (type1);
else
- /* if one of them is a pointer then that
+ /* if one of them is a pointer or array then that
prevails */
- if (IS_PTR (type1))
+ if (IS_PTR (type1) || IS_ARRAY (type1))
rType = copyLinkChain (type1);
- else if (IS_PTR (type2))
+ else if (IS_PTR (type2) || IS_ARRAY (type2))
rType = copyLinkChain (type2);
else if (getSize (type1) > getSize (type2))
rType = copyLinkChain (type1);
{
int i;
+ if (options.all_callee_saves) return 1;
for (i = 0; options.calleeSaves[i]; i++)
if (strcmp (options.calleeSaves[i], s) == 0)
return 1;
DCL_TYPE (val->type) = PPOINTER;
break;
case S_FIXED:
+ if (SPEC_OCLS(val->etype)) {
DCL_TYPE(val->type)=PTR_TYPE(SPEC_OCLS(val->etype));
-
- if (TARGET_IS_DS390)
- {
+ } else {
+#if 1
+ // this happens for (external) function parameters
+ DCL_TYPE (val->type) = GPOINTER;
+#else
+ if (TARGET_IS_DS390) {
/* The AUTO and REGISTER classes should probably
* also become generic pointers, but I haven't yet
* devised a test case for that.
DCL_TYPE (val->type) = GPOINTER;
break;
}
- if (options.model==MODEL_LARGE) {
- DCL_TYPE (val->type) = FPOINTER;
- break;
+ if (options.model==MODEL_LARGE) {
+ DCL_TYPE (val->type) = FPOINTER;
+ break;
+ }
+#endif
}
break;
case S_AUTO:
switch (DCL_TYPE (type))
{
case FUNCTION:
- fprintf (of, "function ");
+ fprintf (of, "function %s", (IFFUNC_ISBUILTIN(type) ? "__builtin__" : " "));
break;
case GPOINTER:
if (DCL_PTR_CONST (type))
}
}
+/*-----------------------------------------------------------------*/
+/* typeFromStr - create a typechain from an encoded string */
+/* basic types - 'c' - char */
+/* 's' - short */
+/* 'i' - int */
+/* 'l' - long */
+/* 'f' - float */
+/* 'v' - void */
+/* '*' - pointer - default (GPOINTER) */
+/* modifiers - 'u' - unsigned */
+/* pointer modifiers - 'g' - generic */
+/* 'x' - xdata */
+/* 'p' - code */
+/* 'd' - data */
+/* examples : "ig*" - generic int * */
+/* "cx*" - char xdata * */
+/* "ui" - unsigned int */
+/*-----------------------------------------------------------------*/
+sym_link *typeFromStr (char *s)
+{
+ sym_link *r = newLink();
+ int usign = 0;
+
+ do {
+ sym_link *nr;
+ switch (*s) {
+ case 'u' :
+ usign = 1;
+ s++;
+ continue ;
+ break ;
+ case 'c':
+ r->class = SPECIFIER;
+ SPEC_NOUN(r) = V_CHAR;
+ break;
+ case 's':
+ case 'i':
+ r->class = SPECIFIER;
+ SPEC_NOUN(r) = V_INT;
+ break;
+ case 'l':
+ r->class = SPECIFIER;
+ SPEC_NOUN(r) = V_INT;
+ SPEC_LONG(r) = 1;
+ break;
+ case 'f':
+ r->class = SPECIFIER;
+ SPEC_NOUN(r) = V_FLOAT;
+ break;
+ case 'v':
+ r->class = SPECIFIER;
+ SPEC_NOUN(r) = V_VOID;
+ break;
+ case '*':
+ DCL_TYPE(r) = GPOINTER;
+ break;
+ case 'g':
+ case 'x':
+ case 'p':
+ case 'd':
+ assert(*(s+1)=='*');
+ nr = newLink();
+ nr->next = r;
+ r = nr;
+ r->class = DECLARATOR ;
+ switch (*s) {
+ case 'g':
+ DCL_TYPE(r) = GPOINTER;
+ break;
+ case 'x':
+ DCL_TYPE(r) = FPOINTER;
+ break;
+ case 'p':
+ DCL_TYPE(r) = CPOINTER;
+ break;
+ case 'd':
+ DCL_TYPE(r) = POINTER;
+ break;
+ }
+ s++;
+ break;
+ default:
+ werror(E_INTERNAL_ERROR,"typeFromStr");
+ break;
+ }
+ if (IS_SPEC(r) && usign) {
+ SPEC_USIGN(r) = 1;
+ usign = 0;
+ }
+ s++;
+ } while (*s);
+ return r;
+}
+
/*-----------------------------------------------------------------*/
/* initCSupport - create functions for C support routines */
/*-----------------------------------------------------------------*/
}
}
}
+
+/*-----------------------------------------------------------------*/
+/* initBuiltIns - create prototypes for builtin functions */
+/*-----------------------------------------------------------------*/
+void initBuiltIns()
+{
+ int i;
+ symbol *sym;
+
+ if (!port->builtintable) return ;
+
+ for (i = 0 ; port->builtintable[i].name ; i++) {
+ sym = funcOfTypeVarg(port->builtintable[i].name,port->builtintable[i].rtype,
+ port->builtintable[i].nParms,port->builtintable[i].parm_types);
+ FUNC_ISBUILTIN(sym->type) = 1;
+ }
+}