@@ -460,12 +460,9 @@ struct ModuleGroup
460460 return true ;
461461 }
462462
463- // `cycle` is set to `true ` if deprecated cycle error otherwise set `result`.
464- void doSort (size_t relevantFlags, ref bool cycle , ref immutable (ModuleInfo )* [] result)
463+ // returns `false ` if deprecated cycle error otherwise set `result`.
464+ bool doSort (size_t relevantFlags, ref immutable (ModuleInfo )* [] result)
465465 {
466- if (cycle)
467- return ;
468-
469466 clearFlags(relevant);
470467 clearFlags(ctorstart);
471468 clearFlags(ctordone);
@@ -495,33 +492,29 @@ struct ModuleGroup
495492 if (! bt(ctordone, idx))
496493 {
497494 if (! processMod(idx))
498- {
499- cycle = true ;
500- return ;
501- }
495+ return false ;
502496 }
503497 }
504498
505499 if (ctoridx == 0 )
506500 {
507501 // no ctors in the list.
508502 .free(ctors);
509- result = null ;
510- return ;
511503 }
512-
513- ctors = cast (immutable (ModuleInfo )** ).realloc(ctors, ctoridx * (void * ).sizeof);
514- if (ctors is null )
515- assert (0 );
516- result = ctors[0 .. ctoridx];
517- return ;
504+ else
505+ {
506+ ctors = cast (immutable (ModuleInfo )** ).realloc(ctors, ctoridx * (void * ).sizeof);
507+ if (ctors is null )
508+ assert (0 );
509+ result = ctors[0 .. ctoridx];
510+ }
511+ return true ;
518512 }
519513
520- // finally, do the sorting for both shared and tls ctors.
521- bool cycle = false ;
522- doSort(MIctor | MIdtor, cycle, _ctors);
523- doSort(MItlsctor | MItlsdtor, cycle, _tlsctors);
524- if (cycle)
514+ // finally, do the sorting for both shared and tls ctors. If either returns false,
515+ // print the deprecation warning.
516+ if (! doSort(MIctor | MIdtor, _ctors) ||
517+ ! doSort(MItlsctor | MItlsdtor, _tlsctors))
525518 {
526519 // print a warning
527520 import core.stdc.stdio : fprintf, stderr;
0 commit comments