Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/template.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,15 @@ int isError(RootObject *o)
return (t->ty == Terror);
Expression *e = isExpression(o);
if (e)
return (e->op == TOKerror || !e->type || e->type->ty== Terror);
return (e->op == TOKerror || !e->type || e->type->ty == Terror);
Tuple *v = isTuple(o);
if (v)
return arrayObjectIsError(&v->objects);
Dsymbol *s = isDsymbol(o);
assert(s);
if (s->errors)
return 1;
return s && s->parent ? isError(s->parent) : 0;
return s->parent ? isError(s->parent) : 0;
}

/**************************************
Expand Down Expand Up @@ -3163,6 +3164,7 @@ MATCH Type::deduceTypeHelper(Type **at, Type *tparam)

default:
assert(0);
return MATCHnomatch; // silence compiler warning about missing return
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd rather we used a function similar to llvm_unreachable which is easy to mark up as __attribute__((noreturn))/__declspec(noreturn).

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd rather we didn't add stuff that doesn't have a translation to D.

Copy link
Contributor

Choose a reason for hiding this comment

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

assert(0, msg) seems like a good D translation of that, because the semantics are actually part of the language there. (Well, actually llvm_unreachable doesn't compile to a trap in release mode, just to the respective equivalent of __builtin_unreachable but that's was not my point here. Anyway, it's a rather minor issue…)

Copy link
Contributor

Choose a reason for hiding this comment

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

There is already an assert(0) here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes?

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm never mind. Still, I'd rather not put and more clang/gcc/msvc extensions into the dmd source, eg I had to special case the noreturn attributes on fatal. We're abandoning C++ after all.

}
#undef X
}
Expand Down