[Issue 7719] enum forward reference error when enum is in braces

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Oct 4 08:30:59 PDT 2012


http://d.puremagic.com/issues/show_bug.cgi?id=7719



--- Comment #2 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2012-10-04 08:25:05 PDT ---
I've found some lead:

in enum.c:

void EnumDeclaration::semantic0(Scope *sc)
{
    /* This function is a hack to get around a significant problem.
     * The members of anonymous enums, like:
     *  enum { A, B, C }
     * don't get installed into the symbol table until after they are
     * semantically analyzed, yet they're supposed to go into the enclosing
     * scope's table. Hence, when forward referenced, they come out as
     * 'undefined'. The real fix is to add them in at addSymbol() time.
     * But to get code to compile, we'll just do this quick hack at the moment
     * to compile it if it doesn't depend on anything else.
     */

    if (isdone || !scope)
        return;
    if (!isAnonymous() || memtype)
        return;
    for (size_t i = 0; i < members->dim; i++)
    {
        EnumMember *em = (*members)[i]->isEnumMember();
        if (em && (em->type || em->value))
            return;
    }

    // Can do it
    semantic(sc);
}

If I remove the for loop and let semantic do its work the OP code compiles. But
I don't know the extent of this hack that's in place now, whether it's still
necessary or not.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list