Skip to content

Commit

Permalink
[flang] Address review comments
Browse files Browse the repository at this point in the history
Original-commit: flang-compiler/f18@b2a0503
Reviewed-on: flang-compiler/f18#774
Tree-same-pre-rewrite: false
  • Loading branch information
klausler committed Oct 2, 2019
1 parent 5c35f32 commit 4ee37ac
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 16 deletions.
2 changes: 1 addition & 1 deletion flang/lib/common/idioms.h
Expand Up @@ -76,7 +76,7 @@ template<typename... LAMBDAS> visitors(LAMBDAS... x)->visitors<LAMBDAS...>;

// For switch statements whose cases have return statements for
// all possibilities. Clang emits warnings if the default: is
// present, gcc emits warings if it is absent.
// present, gcc emits warnings if it is absent.
#if __clang__
#define SWITCH_COVERS_ALL_CASES
#else
Expand Down
7 changes: 3 additions & 4 deletions flang/lib/parser/characters.cc
Expand Up @@ -121,10 +121,9 @@ template<> EncodedCharacter EncodeCharacter<Encoding::UTF_8>(char32_t ucs) {

EncodedCharacter EncodeCharacter(Encoding encoding, char32_t ucs) {
switch (encoding) {
case Encoding::LATIN_1: return EncodeCharacter<Encoding::LATIN_1>(ucs);
case Encoding::UTF_8:
return EncodeCharacter<Encoding::UTF_8>(ucs);
SWITCH_COVERS_ALL_CASES
case Encoding::LATIN_1: return EncodeCharacter<Encoding::LATIN_1>(ucs);
case Encoding::UTF_8: return EncodeCharacter<Encoding::UTF_8>(ucs);
}
}

Expand Down Expand Up @@ -252,11 +251,11 @@ template DecodedCharacter DecodeCharacter<Encoding::UTF_8>(
DecodedCharacter DecodeCharacter(Encoding encoding, const char *cp,
std::size_t bytes, bool backslashEscapes) {
switch (encoding) {
SWITCH_COVERS_ALL_CASES
case Encoding::LATIN_1:
return DecodeCharacter<Encoding::LATIN_1>(cp, bytes, backslashEscapes);
case Encoding::UTF_8:
return DecodeCharacter<Encoding::UTF_8>(cp, bytes, backslashEscapes);
SWITCH_COVERS_ALL_CASES
}
}

Expand Down
2 changes: 1 addition & 1 deletion flang/lib/parser/prescan.cc
Expand Up @@ -58,7 +58,7 @@ static void NormalizeCompilerDirectiveCommentMarker(TokenSequence &dir) {
return;
}
}
CHECK(false && "compiler directive all blank");
DIE("compiler directive all blank");
}

void Prescanner::Prescan(ProvenanceRange range) {
Expand Down
2 changes: 1 addition & 1 deletion flang/lib/semantics/expression.cc
Expand Up @@ -111,6 +111,7 @@ template<template<typename> typename WRAPPER, typename WRAPPED>
common::IfNoLvalue<MaybeExpr, WRAPPED> TypedWrapper(
const DynamicType &dyType, WRAPPED &&x) {
switch (dyType.category()) {
SWITCH_COVERS_ALL_CASES
case TypeCategory::Integer:
return WrapperHelper<TypeCategory::Integer, WRAPPER, WRAPPED>(
dyType.kind(), std::move(x));
Expand All @@ -128,7 +129,6 @@ common::IfNoLvalue<MaybeExpr, WRAPPED> TypedWrapper(
dyType.kind(), std::move(x));
case TypeCategory::Derived:
return AsGenericExpr(Expr<SomeDerived>{WRAPPER<SomeDerived>{std::move(x)}});
SWITCH_COVERS_ALL_CASES
}
}

Expand Down
5 changes: 2 additions & 3 deletions flang/lib/semantics/resolve-names-utils.cc
Expand Up @@ -176,6 +176,7 @@ void GenericSpecInfo::Analyze(const parser::GenericSpec &x) {
// parser::DefinedOperator::IntrinsicOperator -> GenericKind
static GenericKind MapIntrinsicOperator(IntrinsicOperator op) {
switch (op) {
SWITCH_COVERS_ALL_CASES
case IntrinsicOperator::Power: return GenericKind::OpPower;
case IntrinsicOperator::Multiply: return GenericKind::OpMultiply;
case IntrinsicOperator::Divide: return GenericKind::OpDivide;
Expand All @@ -193,9 +194,7 @@ static GenericKind MapIntrinsicOperator(IntrinsicOperator op) {
case IntrinsicOperator::OR: return GenericKind::OpOR;
case IntrinsicOperator::XOR: return GenericKind::OpXOR;
case IntrinsicOperator::EQV: return GenericKind::OpEQV;
case IntrinsicOperator::NEQV:
return GenericKind::OpNEQV;
SWITCH_COVERS_ALL_CASES
case IntrinsicOperator::NEQV: return GenericKind::OpNEQV;
}
}

Expand Down
5 changes: 3 additions & 2 deletions flang/lib/semantics/resolve-names.cc
Expand Up @@ -4805,6 +4805,7 @@ void ConstructVisitor::PopAssociation() {
const DeclTypeSpec &ConstructVisitor::ToDeclTypeSpec(
evaluate::DynamicType &&type) {
switch (type.category()) {
SWITCH_COVERS_ALL_CASES
case common::TypeCategory::Integer:
case common::TypeCategory::Real:
case common::TypeCategory::Complex:
Expand All @@ -4824,7 +4825,7 @@ const DeclTypeSpec &ConstructVisitor::ToDeclTypeSpec(

);
}
case common::TypeCategory::Character: CRASH_NO_CASE; SWITCH_COVERS_ALL_CASES
case common::TypeCategory::Character: CRASH_NO_CASE;
}
}

Expand Down Expand Up @@ -5718,6 +5719,7 @@ void ResolveNamesVisitor::AddSubpNames(const ProgramTree &node) {
// Push a new scope for this node or return false on error.
bool ResolveNamesVisitor::BeginScope(const ProgramTree &node) {
switch (node.GetKind()) {
SWITCH_COVERS_ALL_CASES
case ProgramTree::Kind::Program:
PushScope(Scope::Kind::MainProgram,
&MakeSymbol(node.name(), MainProgramDetails{}));
Expand All @@ -5730,7 +5732,6 @@ bool ResolveNamesVisitor::BeginScope(const ProgramTree &node) {
case ProgramTree::Kind::Module: BeginModule(node.name(), false); return true;
case ProgramTree::Kind::Submodule:
return BeginSubmodule(node.name(), node.GetParentId());
SWITCH_COVERS_ALL_CASES
}
}

Expand Down
5 changes: 2 additions & 3 deletions flang/lib/semantics/scope.cc
Expand Up @@ -212,12 +212,11 @@ bool Scope::CanImport(const SourceName &name) const {
return false;
}
switch (GetImportKind()) {
SWITCH_COVERS_ALL_CASES
case ImportKind::None: return false;
case ImportKind::All:
case ImportKind::Default: return true;
case ImportKind::Only:
return importNames_.count(name) > 0;
SWITCH_COVERS_ALL_CASES
case ImportKind::Only: return importNames_.count(name) > 0;
}
}

Expand Down
2 changes: 1 addition & 1 deletion flang/lib/semantics/type.cc
Expand Up @@ -156,6 +156,7 @@ void ParamValue::SetExplicit(SomeIntExpr &&x) {

std::string ParamValue::AsFortran() const {
switch (category_) {
SWITCH_COVERS_ALL_CASES
case Category::Assumed: return "*";
case Category::Deferred: return ":";
case Category::Explicit:
Expand All @@ -166,7 +167,6 @@ std::string ParamValue::AsFortran() const {
} else {
return "";
}
SWITCH_COVERS_ALL_CASES
}
}

Expand Down

0 comments on commit 4ee37ac

Please sign in to comment.