Changeset 321


Ignore:
Timestamp:
Jun 11, 2003, 9:44:08 PM (22 years ago)
Author:
bird
Message:

#456: forward referenced structures fix (spooky). <,<<,> and >> operator fixes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/emx/src/emxomf/stabshll.c

    • Property cvs2svn:cvs-rev changed from 1.9 to 1.10
    r320 r321  
    2121
    2222
     23/*******************************************************************************
     24*   Header Files                                                               *
     25*******************************************************************************/
    2326#include <stdio.h>
    2427#include <stdlib.h>
     
    3134#include "stabshll.h"
    3235
     36
     37/*******************************************************************************
     38*   Defined Constants And Macros                                               *
     39*******************************************************************************/
    3340/* Field ID values for the type table. */
    3441
     
    8087#define STRUC_FORWARD   0x01    /* Structure declared forward */
    8188
     89
     90/*******************************************************************************
     91*   Structures and Typedefs                                                    *
     92*******************************************************************************/
    8293enum type_tag
    8394{
     
    259270#pragma pack()
    260271
     272
     273/*******************************************************************************
     274*   Global Variables                                                           *
     275*******************************************************************************/
    261276/* This variable points to the next character of a stabs type being
    262277   parsed. */
     
    351366/* kso #456 2003-06-11: Reversed quiet workaround. */
    352367#define no_warning warning
     368
     369
     370/*******************************************************************************
     371*   Internal Functions                                                         *
     372*******************************************************************************/
     373static void parse_typedef (int *index);
     374
     375
    353376
    354377
     
    910933
    911934#endif
     935
     936
     937/**
     938 * Tries to complete a struct forward reference.
     939 *
     940 * @returns 0 on success
     941 * @returns 1 on failure.
     942 * @param   tp  Pointer to the struct/class to complete.
     943 * @remark  Nasy hack for strstreambuf.
     944 */
     945static int try_complete_struct(const struct type *tp)
     946{
     947    int         cch;
     948    const char *pszName;
     949    int         i;
     950
     951    if (tp->tag == ty_struc)
     952        return 0;
     953    if (tp->d.struc.flags != STRUC_FORWARD)
     954        return 1;
     955
     956    pszName = tp->d.struc.name;
     957    cch = strlen(pszName);
     958    for (i = 0; i < sym_count; ++i)
     959        switch (sym_ptr[i].n_type)
     960        {
     961            case N_LSYM:
     962            case N_LCSYM:
     963            case N_GSYM:
     964            case N_PSYM:
     965            case N_RSYM:
     966            case N_STSYM:
     967            case N_FUN:
     968                if (    !memcmp(str_ptr + sym_ptr[i].n_un.n_strx, pszName, cch)
     969                    &&  *(char*)(str_ptr + sym_ptr[i].n_un.n_strx + cch) == ':'
     970                    )
     971                {
     972                    parse_typedef(&i);
     973                    return 1;
     974                } /* if */
     975        } /* switch */
     976
     977    return 0;
     978}
     979
    912980
    913981
     
    9551023    case ty_stabs_ref:
    9561024
     1025      #if 0
    9571026      /* This should not happen. */
    9581027
    9591028      no_warning ("stabs type %d not defined", tp->d.stabs_ref);
     1029
    9601030      return 4;
     1031      #else
     1032      /* This seems to happen although it shouldn't... Try do something at least. */
     1033
     1034      tp = follow_refs (tp);
     1035      if (!tp)
     1036        {
     1037          no_warning ("stabs type %d not defined", tp->d.stabs_ref);
     1038          return 4;
     1039        }
     1040      return type_size (tp);
     1041      #endif
    9611042
    9621043    case ty_alias:
     
    9771058      /* The size of a structure is stored in the type structure. */
    9781059
    979       if (tp->d.struc.flags & STRUC_FORWARD)
    980         {
    981           no_warning ("size of incomplete structure %s is unknown",
    982                    tp->d.struc.name);
     1060      if (   tp->d.struc.flags & STRUC_FORWARD
     1061          && try_complete_struct(tp))
     1062        {
     1063          no_warning ("size of incomplete structure %s is unknown (off %ld)\n stabs: %s",
     1064                      tp->d.struc.name, parse_ptr - parse_start, parse_start);
    9831065          return 0;
    9841066        }
     
    13781460        {
    13791461          case '<':
     1462            #if 0
     1463            /* workaround for "operator<::" and "operator<::"
     1464             *  */
     1465            if (!cNesting  || (psz[1] == ':' && psz[2] == ':'))
     1466                return psz + 1;
     1467            if (!cNesting  || (psz[1] == '<' && psz[2] == ':' && psz[3] == ':'))
     1468                return psz + 2;
     1469            #else
     1470            /* general and faster check: < or > followed by : means the end. */
     1471            #endif
     1472            if (psz[1] == ':')
     1473              return psz + 1;
    13801474            cNesting++;
    13811475            break;
    13821476          case '>':
     1477            if (psz[1] == ':')
     1478              return psz + 1;
    13831479            cNesting--;
    13841480            break;
Note: See TracChangeset for help on using the changeset viewer.