4768 – Regression(1.056): wrong code with forward declaration of enum

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 4768 - Regression(1.056): wrong code with forward declaration of enum
Summary: Regression(1.056): wrong code with forward declaration of enum
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: Other Windows
: P2 regression
Assignee: No Owner
URL:
Keywords: patch, wrong-code
Depends on:
Blocks: 340
Show dependency tree / graph
Reported: 2010年08月29日 23:57 UTC by Don
Modified: 2010年09月21日 19:21 UTC (History)
2 users (show)

See Also:


Attachments
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description Don 2010年08月29日 23:57:56 UTC
This is the D1 version of bug 4516.
Rejected as 'forward reference error' up to D1.053.
Worked correctly in 1.054 and 1.055. Wrong code in 1.056 and later.
Works if the definition of B is moved above A.
struct A { B b; }
enum B { Z = 2 }
void main()
{
 A x;
 assert(x.b == 2);
}
Comment 1 Don 2010年09月13日 16:39:04 UTC
mtype.c, line 4110. Basically the same patch as bug 4516.
int TypeEnum::isZeroInit(Loc loc)
{
+ if (!sym->isdone && sym->scope)
+ { // Enum is forward referenced. We need to resolve the whole thing.
+ sym->semantic(NULL);
+ }
+ if (!sym->isdone)
+ {
+ error(loc, "enum %s is forward referenced", sym->toChars());
+ return 0;
+ }
 return (sym->defaultval == 0);
}
Comment 2 Walter Bright 2010年09月21日 19:21:45 UTC
http://www.dsource.org/projects/dmd/changeset/682 


AltStyle によって変換されたページ (->オリジナル) /