Skip to content

Commit

Permalink
Remove redundant flow control following assert(0)
Browse files Browse the repository at this point in the history
  • Loading branch information
yebblies committed Sep 17, 2015
1 parent 5315d2d commit 36aadab
Show file tree
Hide file tree
Showing 17 changed files with 7 additions and 55 deletions.
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);
}
//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
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
2 changes: 0 additions & 2 deletions src/statement.d
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ public:
Statement syntaxCopy()
{
assert(0);
return null;
}

final void print()
Expand Down Expand Up @@ -273,7 +272,6 @@ public:
printf("Statement::blockExit(%p)\n", s);
printf("%s\n", s.toChars());
assert(0);
result = BEany;
}

void visit(ErrorStatement s)
Expand Down
Loading

0 comments on commit 36aadab

Please sign in to comment.