Changeset 615


Ignore:
Timestamp:
Aug 16, 2003, 9:31:23 PM (22 years ago)
Author:
zap
Message:

.

Location:
trunk/src/gcc/gcc/config/i386
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gcc/gcc/config/i386/emx.c

    • Property cvs2svn:cvs-rev changed from 1.16 to 1.17
    r614 r615  
    9595#endif
    9696
    97 
    9897tree ix86_handle_vacpp_attribute (tree *node, tree name, tree args,
    9998  int flags, bool *no_add_attrs)
     
    113112           an attached attribute (either optlink or system).
    114113           This is the only part which is changing the mangling. */
     114
     115        type = TREE_TYPE (*node);
     116
     117        if (ix86_check_append_attr (type, name, no_add_attrs))
     118          break;
     119
    115120        if (is_attribute_p ("system", name))
    116121          {
     
    122127                CLASSTYPE_DECLARED_CLASS (meaning it doesn't apply to plain
    123128                structs/unions) ? */
    124             if (   TREE_CODE (TREE_TYPE (*node)) != METHOD_TYPE
     129            if (   TREE_CODE (type) != METHOD_TYPE
    125130                && (   !(context = DECL_CONTEXT (*node))
    126131                    || (   TREE_CODE (context) != RECORD_TYPE
     
    171176        /* The attribute should really be attached to our _TYPE
    172177           rather than to the _DECL. */
    173         type = TREE_TYPE (*node);
    174178        TYPE_ATTRIBUTES (type) = chainon (TYPE_ATTRIBUTES (type),
    175179                                          tree_cons (name, args, NULL_TREE));
     
    192196            || TREE_CODE (type) == METHOD_TYPE)
    193197          {
     198            if (ix86_check_append_attr (type, name, no_add_attrs))
     199              break;
     200
    194201            /* Attach the attribute to the (FUNCTION|METHOD)_TYPE node */
    195202            TYPE_ATTRIBUTES (type) = chainon (TYPE_ATTRIBUTES (type),
     
    198205            break;
    199206          }
    200         warning ("`%s' attribute only applies to functions and function types (typecode=%d)",
    201                  IDENTIFIER_POINTER (name), type ? (int)TREE_CODE (type) : -1);
     207        warning ("`%s' attribute only applies to functions and function types",
     208                 IDENTIFIER_POINTER (name));
    202209        *no_add_attrs = true;
    203210        break;
  • trunk/src/gcc/gcc/config/i386/i386-protos.h

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r614 r615  
    183183
    184184#ifdef TREE_CODE
     185extern int ix86_check_append_attr PARAMS ((tree, tree, bool *));
     186
    185187extern int ix86_return_pops_args PARAMS ((tree, tree, int));
    186188extern tree ix86_build_va_list PARAMS ((void));
  • trunk/src/gcc/gcc/config/i386/i386.c

    • Property cvs2svn:cvs-rev changed from 1.6 to 1.7
    r614 r615  
    12961296};
    12971297
     1298/* Check if we don't have incompatible calling conversion attributes */
     1299int
     1300ix86_check_append_attr (tree type, tree name, bool *no_add_attrs)
     1301{
     1302  /* ??? use ix86_comp_type_attributes maybe ??? */
     1303  unsigned i;
     1304  const char *exclname;
     1305  static const char *cc [] =
     1306  {
     1307    "cdecl",
     1308    "stdcall",
     1309    "regparm",
     1310#ifdef TARGET_SYSTEM_DECL_ATTRIBUTES
     1311    "system",
     1312#endif
     1313#ifdef TARGET_OPTLINK_DECL_ATTRIBUTES
     1314    "optlink",
     1315#endif
     1316  };
     1317
     1318  exclname = IDENTIFIER_POINTER (name);
     1319  if (exclname [0] == '_')
     1320    {
     1321      /* Remove leading and trailing underscores */
     1322      const char *x1, *x2;
     1323      char *newname;
     1324      x1 = exclname + 1;
     1325      while (*x1 == '_')
     1326        x1++;
     1327      x2 = strchr (x1, 0);
     1328      while (x2 [-1] == '_' && x2 > x1)
     1329        x2--;
     1330      newname = alloca (x2 - x1 + 1);
     1331      memcpy (newname, x1, x2 - x1);
     1332      newname [x2 - x1] = 0;
     1333      exclname = newname;
     1334    }
     1335
     1336  for (i = 0; i < sizeof (cc) / sizeof (const char *); i++)
     1337    if (lookup_attribute (cc [i], TYPE_ATTRIBUTES (type)))
     1338      {
     1339        /* Warn if we have another calling convention attribute and it is
     1340           different from the currently processed attribute. If there is
     1341           already an attribute with the same name attached, silently ignore
     1342           currently processed attribute. */
     1343        if (strcmp (exclname, cc [i]))
     1344          warning ("`%s' attribute is incompatible with earlier defined `%s' attribute",
     1345                   IDENTIFIER_POINTER (name), cc [i]);
     1346        *no_add_attrs = true;
     1347        return -1;
     1348      }
     1349
     1350  return 0;
     1351}
     1352
    12981353/* Handle a "cdecl" or "stdcall" attribute;
    12991354   arguments as in struct attribute_spec.handler.  */
     
    13221377    }
    13231378
     1379  /* Check if the attributes are compatible */
     1380  if (ix86_check_append_attr (*node, name, no_add_attrs))
     1381    return NULL_TREE;
     1382
    13241383  return NULL_TREE;
    13251384}
     
    13631422    }
    13641423
     1424  /* Check if the attributes are compatible */
     1425  if (ix86_check_append_attr (*node, name, no_add_attrs))
     1426    return NULL_TREE;
     1427
    13651428  return NULL_TREE;
    13661429}
     
    14741537     tree type2;
    14751538{
    1476   /* Check for mismatch of non-default calling convention.  */
    1477   const char *const rtdstr = TARGET_RTD ? "cdecl" : "stdcall";
    1478 
    1479 /*
    1480 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ TODO: check for optlink and system
    1481 #ifdef SUBTARGET_COMP_TYPE_ATTRIBUTES
    1482   SUBTARGET_COMP_TYPE_ATTRIBUTES
     1539  unsigned i;
     1540  unsigned char cc1 = 0, cc2 = 0;
     1541  static struct
     1542  {
     1543    const char *attr;
     1544    unsigned char flag;
     1545  } typecode [] =
     1546  {
     1547    { "cdecl",   0x10 },
     1548    { "stdcall", 0x20 },
     1549    { "regparm", 0x30 },
     1550#ifdef TARGET_SYSTEM_DECL_ATTRIBUTES
     1551    { "system",  0x11 },
    14831552#endif
    1484 */
    1485 
     1553#ifdef TARGET_OPTLINK_DECL_ATTRIBUTES
     1554    { "optlink", 0x40 },
     1555#endif
     1556  };
     1557
     1558  /* The following calling conventions have meaning only for functions */
    14861559  if (TREE_CODE (type1) != FUNCTION_TYPE)
    14871560    return 1;
    14881561
    1489   /* Check for mismatched return types (cdecl vs stdcall).  */
    1490   if (!lookup_attribute (rtdstr, TYPE_ATTRIBUTES (type1))
    1491       != !lookup_attribute (rtdstr, TYPE_ATTRIBUTES (type2)))
     1562  /* The function may have only one calling convention.
     1563   * For simplicity we translate the calling conversion attribute
     1564   * to a numeric constant, then the numbers are compared.
     1565   *
     1566   * If the top 4 bits are the same, the types are compatible
     1567   * (e.g. issue a warning but allow the operation).
     1568   */
     1569
     1570  for (i = 0; i < sizeof (typecode) / sizeof (typecode [0]); i++)
     1571    {
     1572      if (lookup_attribute (typecode [i].attr, TYPE_ATTRIBUTES (type1)))
     1573        cc1 = typecode [i].flag;
     1574      if (lookup_attribute (typecode [i].attr, TYPE_ATTRIBUTES (type2)))
     1575        cc2 = typecode [i].flag;
     1576    }
     1577
     1578  if (!cc1)
     1579    cc1 = TARGET_RTD ? 0x20 : 0x10;
     1580  if (!cc2)
     1581    cc2 = TARGET_RTD ? 0x20 : 0x10;
     1582
     1583  /* If calling conventions are the same, its okay */
     1584  if (cc1 == cc2)
     1585    return 1;
     1586
     1587  /* If they are not compatible, return 0 */
     1588  if ((cc1 ^ cc2) & 0xf0)
    14921589    return 0;
    1493   return 1;
     1590
     1591  /* They are nearly compatible, issue a warning */
     1592  return 2;
    14941593}
    14951594
Note: See TracChangeset for help on using the changeset viewer.