[flang] Final tweaks

Original-commit: flang-compiler/f18@6e269b4e29
Reviewed-on: https://github.com/flang-compiler/f18/pull/774
This commit is contained in:
peter klausler 2019-10-02 16:52:27 -07:00
parent 07d48c0a23
commit 9b37989e05
2 changed files with 6 additions and 3 deletions

View File

@ -71,17 +71,19 @@ template<typename... LAMBDAS> visitors(LAMBDAS... x)->visitors<LAMBDAS...>;
#define DIE(x) Fortran::common::die(x " at " __FILE__ "(%d)", __LINE__)
// For switch statements without default: labels.
// For switch statement default: labels.
#define CRASH_NO_CASE DIE("no case")
// clang-format off
// For switch statements whose cases have return statements for
// all possibilities. Clang emits warnings if the default: is
// present, gcc emits warnings if it is absent.
#if __clang__
#define SWITCH_COVERS_ALL_CASES
#else
#define SWITCH_COVERS_ALL_CASES default:;
#define SWITCH_COVERS_ALL_CASES default: CRASH_NO_CASE;
#endif
// clang-format on
// For cheap assertions that should be applied in production.
// To disable, compile with '-DCHECK=(void)'

View File

@ -246,13 +246,14 @@ bool DeclTypeSpec::operator==(const DeclTypeSpec &that) const {
std::string DeclTypeSpec::AsFortran() const {
switch (category_) {
SWITCH_COVERS_ALL_CASES
case Numeric: return numericTypeSpec().AsFortran();
case Logical: return logicalTypeSpec().AsFortran();
case Character: return characterTypeSpec().AsFortran();
case TypeDerived: return "TYPE(" + derivedTypeSpec().AsFortran() + ')';
case ClassDerived: return "CLASS(" + derivedTypeSpec().AsFortran() + ')';
case TypeStar: return "TYPE(*)";
case ClassStar: return "CLASS(*)"; SWITCH_COVERS_ALL_CASES
case ClassStar: return "CLASS(*)";
}
}