Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove dead code and deprecated syntax #5092

Merged
merged 2 commits into from
Sep 17, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 0 additions & 4 deletions src/constfold.d
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ extern (C++) int isConst(Expression e)
return 0;
}
assert(0);
return 0;
}

/* =============================== constFold() ============================== */
Expand Down Expand Up @@ -1599,7 +1598,6 @@ extern (C++) void sliceAssignArrayLiteralFromString(ArrayLiteralExp existingAE,
break;
default:
assert(0);
break;
}
(*existingAE.elements)[j + firstIndex] = new IntegerExp(newval.loc, val, elemType);
}
Expand Down Expand Up @@ -1627,7 +1625,6 @@ extern (C++) void sliceAssignStringFromArrayLiteral(StringExp existingSE, ArrayL
break;
default:
assert(0);
break;
}
}
}
Expand Down Expand Up @@ -1679,7 +1676,6 @@ extern (C++) int sliceCmpStringWithArray(StringExp se1, ArrayLiteralExp ae2, siz
break;
default:
assert(0);
break;
}
int c = val1 - val2;
if (c)
Expand Down
6 changes: 0 additions & 6 deletions src/ctfeexpr.d
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@ public:
return cast(char*)"<goto>";
default:
assert(0);
return null;
}
}

Expand Down Expand Up @@ -458,7 +457,6 @@ extern (C++) UnionExp copyLiteral(Expression e)
}
e.error("CTFE internal error: literal %s", e.toChars());
assert(0);
return ue;
}

/* Deal with type painting.
Expand Down Expand Up @@ -572,7 +570,6 @@ extern (C++) uinteger_t resolveArrayLength(Expression e)
return ale.keys.dim;
}
assert(0);
return 0;
}

/******************************
Expand Down Expand Up @@ -648,7 +645,6 @@ extern (C++) TypeAArray toBuiltinAAType(Type t)
if (t.ty == Taarray)
return cast(TypeAArray)t;
assert(0);
return null;
}

/************** TypeInfo operations ************************************/
Expand Down Expand Up @@ -1019,7 +1015,6 @@ extern (C++) void intUnary(TOK op, IntegerExp e)
break;
default:
assert(0);
break;
}
}

Expand Down Expand Up @@ -1666,7 +1661,6 @@ extern (C++) int ctfeRawCmp(Loc loc, Expression e1, Expression e2)
}
error(loc, "CTFE internal error: bad compare");
assert(0);
return 0;
}

/// Evaluate ==, !=. Resolves slices before comparing. Returns 0 or 1
Expand Down
3 changes: 0 additions & 3 deletions src/declaration.d
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,6 @@ public:
Dsymbol syntaxCopy(Dsymbol s)
{
assert(0);
return null;
}

const(char)* kind()
Expand Down Expand Up @@ -2364,7 +2363,6 @@ public:
final Dsymbol syntaxCopy(Dsymbol s)
{
assert(0); // should never be produced by syntax
return null;
}

final void semantic(Scope* sc)
Expand Down Expand Up @@ -2808,7 +2806,6 @@ public:
Dsymbol syntaxCopy(Dsymbol s)
{
assert(0); // should never be produced by syntax
return null;
}

ThisDeclaration isThisDeclaration()
Expand Down
11 changes: 1 addition & 10 deletions src/dinterpret.d
Original file line number Diff line number Diff line change
Expand Up @@ -2228,7 +2228,6 @@ public:
// var should have been initialized when it was created
error(loc, "CTFE internal error: trying to access uninitialized var");
assert(0);
return CTFEExp.cantexp;
}
e = v._init.toExpression();
}
Expand Down Expand Up @@ -3227,7 +3226,6 @@ public:
default:
printf("be = '%s' %s at [%s]\n", Token.toChars(e.op), e.toChars(), e.loc.toChars());
assert(0);
return;
}
}

Expand Down Expand Up @@ -3768,7 +3766,6 @@ public:
break;
default:
assert(0);
break;
}
return null;
}
Expand Down Expand Up @@ -4034,7 +4031,6 @@ public:
break;
default:
assert(0);
break;
}
}
if (goal == ctfeNeedNothing)
Expand Down Expand Up @@ -4294,7 +4290,6 @@ public:
return;
default:
assert(0);
return;
}
}

Expand Down Expand Up @@ -4362,7 +4357,7 @@ public:
case TOKlt:
return TOKge;
default:
return assert(0), TOKreserved;
assert(0);
}
}

Expand Down Expand Up @@ -5082,7 +5077,6 @@ public:
if (goal == ctfeNeedLvalue && e1.type.ty == Taarray && e.modifiable)
{
assert(0); // does not reach here?
return;
}
e.error("cannot index null array %s", e.e1.toChars());
result = CTFEExp.cantexp;
Expand Down Expand Up @@ -5863,13 +5857,11 @@ public:
{
e.error("CTFE internal error: trying to read uninitialized variable");
assert(0);
result = CTFEExp.cantexp;
}

void visit(ThrownExceptionExp e)
{
assert(0); // This should never be interpreted
result = e;
}
}

Expand Down Expand Up @@ -6576,7 +6568,6 @@ extern (C++) Expression evaluatePostblit(InterState* istate, Expression e)
return null;
}
assert(0);
return null;
}

extern (C++) Expression evaluateDtor(InterState* istate, Expression e)
Expand Down
1 change: 0 additions & 1 deletion src/dmangle.d
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,6 @@ public:
default:
fprintf(stderr, "'%s', linkage = %d\n", d.toChars(), d.linkage);
assert(0);
return;
}
}
buf.writestring("_D");
Expand Down
1 change: 0 additions & 1 deletion src/dscope.d
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,6 @@ struct Scope
}
}
assert(0);
return null;
}

/********************************************
Expand Down
1 change: 0 additions & 1 deletion src/dsymbol.d
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,6 @@ public:
print();
printf("%s %s\n", kind(), toChars());
assert(0);
return null;
}

/**************************************
Expand Down
5 changes: 1 addition & 4 deletions src/dtemplate.d
Original file line number Diff line number Diff line change
Expand Up @@ -1688,7 +1688,7 @@ public:
default:
goto Lnomatch;
}
++argi;
assert(0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this change looks suspicious

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's wrong then there's a compiler bug in dead code detection.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The easiest way to find out what caused the regression is to back all these changes out, then add them one by one until the regression happens.

}
//printf("-> argi = %d, nfargs = %d, nfargs2 = %d\n", argi, nfargs, nfargs2);
if (argi != nfargs2 && !fvarargs)
Expand Down Expand Up @@ -2976,7 +2976,6 @@ extern (C++) MATCH deduceTypeHelper(Type t, Type* at, Type tparam)
return MATCHnomatch;
default:
assert(0);
return MATCHnomatch; // silence compiler warning about missing return
}
}

Expand Down Expand Up @@ -3364,8 +3363,6 @@ extern (C++) MATCH deduceType(RootObject o, Scope* sc, Type tparam, TemplatePara
}
}
visit(cast(Type)t);
return;
result = MATCHnomatch;
}

void visit(TypeAArray t)
Expand Down
1 change: 0 additions & 1 deletion src/expression.d
Original file line number Diff line number Diff line change
Expand Up @@ -4415,7 +4415,6 @@ public:
break;
default:
assert(0);
break;
}
return value;
}
Expand Down
4 changes: 0 additions & 4 deletions src/hdrgen.d
Original file line number Diff line number Diff line change
Expand Up @@ -1194,7 +1194,6 @@ public:
break;
default:
assert(0);
break;
}
buf.writestring("extern (");
buf.writestring(p);
Expand Down Expand Up @@ -3062,7 +3061,6 @@ extern (C++) const(char)* trustToChars(TRUST trust)
default:
assert(0);
}
return null; // never reached
}

extern (C++) void linkageToBuffer(OutBuffer* buf, LINK linkage)
Expand Down Expand Up @@ -3097,7 +3095,6 @@ extern (C++) const(char)* linkageToChars(LINK linkage)
default:
assert(0);
}
return null; // never reached
}

extern (C++) void protectionToBuffer(OutBuffer* buf, Prot prot)
Expand Down Expand Up @@ -3134,7 +3131,6 @@ extern (C++) const(char)* protectionToChars(PROTKIND kind)
default:
assert(0);
}
return null; // never reached
}

// Print the full function signature with correct ident, attributes and template args
Expand Down
2 changes: 1 addition & 1 deletion src/lexer.d
Original file line number Diff line number Diff line change
Expand Up @@ -1861,7 +1861,7 @@ public:
alias FLAGS_decimal = FLAGS.FLAGS_decimal;
alias FLAGS_unsigned = FLAGS.FLAGS_unsigned;
alias FLAGS_long = FLAGS.FLAGS_long;
;

FLAGS flags = (base == 10) ? FLAGS_decimal : FLAGS_none;
// Parse trailing 'u', 'U', 'l' or 'L' in any combination
const(char)* psuffix = p;
Expand Down
11 changes: 4 additions & 7 deletions src/mtype.d
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,6 @@ public:
const(char)* kind()
{
assert(false); // should be overridden
return null;
}

final Type copy()
Expand All @@ -613,7 +612,6 @@ public:
print();
fprintf(stderr, "ty = %d\n", ty);
assert(0);
return this;
}

bool equals(RootObject o)
Expand Down Expand Up @@ -3416,7 +3414,6 @@ public:
break;
default:
assert(0);
break;
}
//printf("TypeBasic::size() = %d\n", size);
return size;
Expand Down Expand Up @@ -7926,10 +7923,10 @@ public:
{
assert(0); // cannot find a case where this happens; leave
// assert in until we do
ScopeExp se = cast(ScopeExp)de.e1;
s = se.sds.search(e.loc, ident);
e = de.e1;
goto L1;
// ScopeExp se = cast(ScopeExp)de.e1;
// s = se.sds.search(e.loc, ident);
// e = de.e1;
// goto L1;
}
}
s = sym.search(e.loc, ident);
Expand Down
4 changes: 0 additions & 4 deletions src/objc_stubs.d
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,18 @@ struct ObjcSelector
{
printf("Should never be called when D_OBJC is false\n");
assert(0);
return null;
}

extern (C++) static ObjcSelector* lookup(const(char)* s, size_t len, size_t pcount)
{
printf("Should never be called when D_OBJC is false\n");
assert(0);
return null;
}

extern (C++) static ObjcSelector* create(FuncDeclaration fdecl)
{
printf("Should never be called when D_OBJC is false\n");
assert(0);
return null;
}
}

Expand Down Expand Up @@ -104,7 +101,6 @@ extern (C++) bool objc_isUdaSelector(StructDeclaration sd)
{
printf("Should never be called when D_OBJC is false\n");
assert(0);
return false;
}

extern (C++) void objc_FuncDeclaration_semantic_validateSelector(FuncDeclaration fd)
Expand Down
3 changes: 0 additions & 3 deletions src/parse.d
Original file line number Diff line number Diff line change
Expand Up @@ -2911,7 +2911,6 @@ public:
break;
default:
assert(0);
break;
}
if (a && token.value == TOKsemicolon)
{
Expand Down Expand Up @@ -3517,7 +3516,6 @@ public:
assert(0);
}
assert(0);
return null;
}

Type parseDeclarator(Type t, int* palt, Identifier* pident, TemplateParameters** tpl = null, StorageClass storageClass = 0, int* pdisable = null, Expressions** pudas = null)
Expand Down Expand Up @@ -4477,7 +4475,6 @@ public:
goto Ldeclaration;
else
goto Lexp;
break;
case TOKassert:
case TOKthis:
case TOKsuper:
Expand Down
1 change: 0 additions & 1 deletion src/root/filename.d
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,6 @@ struct FileName
else
{
assert(0);
return null;
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/root/longdouble.d
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ size_t ld_sprint(char* str, int fmt, real x)
// ((1.5 -> 1 -> 1.0) == 1.5) is false
// ((1.0 -> 1 -> 1.0) == 1.0) is true
// see http://en.cppreference.com/w/cpp/io/c/fprintf
char sfmt[5] = "%#Lg\0";
char[5] sfmt = "%#Lg\0";
sfmt[3] = cast(char)fmt;
return sprintf(str, sfmt.ptr, x);
}
else
{
char sfmt[4] = "%Lg\0";
char[4] sfmt = "%Lg\0";
sfmt[2] = cast(char)fmt;
return sprintf(str, sfmt.ptr, x);
}
Expand Down