@@ -25,7 +25,7 @@ import dmd.declaration;
2525import dmd.dscope;
2626import dmd.dstruct;
2727import dmd.dsymbol;
28- import dmd.dsymbolsem : dsymbolSemantic, determineFields, search, determineSize, include;
28+ import dmd.dsymbolsem : dsymbolSemantic, determineSize, include;
2929import dmd.dtemplate;
3030import dmd.errors;
3131import dmd.expression;
@@ -37,7 +37,6 @@ import dmd.identifier;
3737import dmd.location;
3838import dmd.mtype;
3939import dmd.tokens;
40- import dmd.typesem : defaultInit, addMod, size;
4140import dmd.visitor;
4241
4342/**
@@ -195,86 +194,6 @@ extern (C++) abstract class AggregateDeclaration : ScopeDsymbol
195194 return ok ? structsize : SIZE_INVALID ;
196195 }
197196
198- /* **************************************
199- * Calculate field[i].overlapped and overlapUnsafe, and check that all of explicit
200- * field initializers have unique memory space on instance.
201- * Returns:
202- * true if any errors happen.
203- */
204- extern (D ) final bool checkOverlappedFields()
205- {
206- // printf("AggregateDeclaration::checkOverlappedFields() %s\n", toChars());
207- assert (sizeok == Sizeok.done);
208- size_t nfields = fields.length;
209- if (isNested())
210- {
211- auto cd = isClassDeclaration();
212- if (! cd || ! cd.baseClass || ! cd.baseClass.isNested())
213- nfields-- ;
214- if (vthis2 && ! (cd && cd.baseClass && cd.baseClass.vthis2))
215- nfields-- ;
216- }
217- bool errors = false ;
218-
219- // Fill in missing any elements with default initializers
220- foreach (i; 0 .. nfields)
221- {
222- auto vd = fields[i];
223- if (vd.errors)
224- {
225- errors = true ;
226- continue ;
227- }
228-
229- const vdIsVoidInit = vd._init && vd._init.isVoidInitializer();
230-
231- // Find overlapped fields with the hole [vd.offset .. vd.offset.size()].
232- foreach (j; 0 .. nfields)
233- {
234- if (i == j)
235- continue ;
236- auto v2 = fields[j];
237- if (v2.errors)
238- {
239- errors = true ;
240- continue ;
241- }
242- if (! vd.isOverlappedWith(v2))
243- continue ;
244-
245- // vd and v2 are overlapping.
246- vd.overlapped = true ;
247- v2.overlapped = true ;
248-
249- if (! MODimplicitConv(vd.type.mod, v2.type.mod))
250- v2.overlapUnsafe = true ;
251- if (! MODimplicitConv(v2.type.mod, vd.type.mod))
252- vd.overlapUnsafe = true ;
253-
254- if (i > j)
255- continue ;
256-
257- if (! v2._init)
258- continue ;
259-
260- if (v2._init.isVoidInitializer())
261- continue ;
262-
263- if (vd._init && ! vdIsVoidInit && v2._init)
264- {
265- .error(loc, " overlapping default initialization for field `%s` and `%s`" , v2.toChars(), vd.toChars());
266- errors = true ;
267- }
268- else if (v2._init && i < j)
269- {
270- .error(v2.loc, " union field `%s` with default initialization `%s` must be before field `%s`" ,
271- v2.toChars(), dmd.hdrgen.toChars(v2._init), vd.toChars());
272- errors = true ;
273- }
274- }
275- }
276- return errors;
277- }
278197
279198 override final Type getType ()
280199 {
@@ -433,46 +352,6 @@ extern (C++) abstract class AggregateDeclaration : ScopeDsymbol
433352 return visibility.kind == Visibility.Kind.export_;
434353 }
435354
436- /* ******************************************
437- * Look for constructor declaration.
438- */
439- extern (D ) final Dsymbol searchCtor()
440- {
441- auto s = this .search(Loc.initial, Id.ctor);
442- if (s)
443- {
444- if (! (s.isCtorDeclaration() ||
445- s.isTemplateDeclaration() ||
446- s.isOverloadSet()))
447- {
448- error(s.loc, " %s name `__ctor` is not allowed" , s.kind);
449- errorSupplemental(s.loc, " identifiers starting with `__` are reserved for internal use" );
450- errors = true ;
451- s = null ;
452- }
453- }
454- if (s && s.toParent() != this )
455- s = null ; // search() looks through ancestor classes
456- if (s)
457- {
458- // Finish all constructors semantics to determine this.noDefaultCtor.
459- static int searchCtor (Dsymbol s, void * )
460- {
461- auto f = s.isCtorDeclaration();
462- if (f && f.semanticRun == PASS .initial)
463- f.dsymbolSemantic(null );
464- return 0 ;
465- }
466-
467- for (size_t i = 0 ; i < members.length; i++ )
468- {
469- auto sm = (* members)[i];
470- sm.apply(&searchCtor, null );
471- }
472- }
473- return s;
474- }
475-
476355 override final Visibility visible () pure nothrow @nogc @safe
477356 {
478357 return visibility;
0 commit comments