www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4516] New: forward declaration of enum not supported

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4516

           Summary: forward declaration of enum not supported
           Product: D
           Version: D2
          Platform: Other
        OS/Version: All
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: braddr puremagic.com



---
module foo;

struct A { B b; }
enum B { Z }

$ dmd -c foo.d
foo.d(3): Error: enum B is forward referenced

(flagging as D2 only since I haven't tested with D1 -- quite possibly broken
with both)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 27 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4516


Leandro Lucarella <llucax gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |llucax gmail.com



PDT ---

 (flagging as D2 only since I haven't tested with D1 -- quite possibly broken
 with both)
Nope, D2-only (at least svn r584 works). -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 27 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4516


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug yahoo.com.au





 (flagging as D2 only since I haven't tested with D1 -- quite possibly broken
 with both)
Nope, D2-only (at least svn r584 works).
It failed up to D1.053. It works in D1.054 and later. Interestingly it also worked in D2.038 and 2.039 ONLY (released with 1.054), it had failed in 2.037 and earlier, but failed again starting with 2.040. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 27 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4516


Stewart Gordon <smjg iname.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |smjg iname.com
             Blocks|                            |340
           Severity|normal                      |regression


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 27 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4516




11:41:50 PDT ---
See bug 1160

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 28 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4516


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch
            Summary|forward declaration of enum |Regression(2.040): forward
                   |not supported               |declaration of enum not
                   |                            |supported



The fix to bug 1160 was what originally fixed it (in toBasetype(), do full
semantic on the enum type when forward referenced); the fix to bug 3723 broke
it again (in toBasetype(), only do semantic on the type, not on the full enum).
In this situation, it does actually does the need the full semantic to be run.

Although this test case passes in D1, I'm not convinced that D1 is correct (it
doesn't check for forward references at all).
----
PATCH: mtype.c, line 6340.

int TypeEnum::isZeroInit(Loc loc)
{
+    if (!sym->defaultval && sym->scope)
+    {   // Enum is forward referenced. We need to resolve the whole thing.
+        sym->semantic(NULL);
+    }
    if (!sym->defaultval)
    {
#ifdef DEBUG
        printf("3: ");
#endif
        error(loc, "enum %s is forward referenced", sym->toChars());
        return 0;
    }
    return sym->defaultval->isBool(FALSE);
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 06 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4516


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla digitalmars.com
            Version|D2                          |D1



20:51:50 PDT ---
You're right that D1 doesn't check for it, as defaultVal is just an integer.
I'll apply your fix for D2, but leave the bug open for D1.

http://www.dsource.org/projects/dmd/changeset/605

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 08 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4516


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED



I have moved the D1 version of this bug into the newly created bug 4768. Both
symptoms and solution are different for D1.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 30 2010
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4516


Stewart Gordon <smjg iname.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Version|D1                          |D2



But you left this one filed as a D1 bug.

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