From: peter klausler Date: Fri, 18 Jun 2021 23:55:37 +0000 (-0700) Subject: [flang] Recode a switch() to dodge a sketchy warning X-Git-Tag: llvmorg-14-init~3572 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b3c1f53c989f6aefad581955e3add222cfb5d890;p=platform%2Fupstream%2Fllvm.git [flang] Recode a switch() to dodge a sketchy warning One of the buildbots uses a compiler (can't tell which) that doesn't approve of a "default:" in a switch statement whose cases appear to completely cover all possible values of an enum class. But this switch is in raw data dumping code that needs to allow for incorrect values in memory. So rewrite it as a cascade of if statements; performance doesn't matter here. --- diff --git a/flang/runtime/type-info.cpp b/flang/runtime/type-info.cpp index ef3c472..df72fc4 100644 --- a/flang/runtime/type-info.cpp +++ b/flang/runtime/type-info.cpp @@ -158,22 +158,16 @@ FILE *Component::Dump(FILE *f) const { std::fprintf(f, "Component @ 0x%p:\n", reinterpret_cast(this)); std::fputs(" name: ", f); DumpScalarCharacter(f, name(), "Component::name"); - switch (genre_) { - case Genre::Data: + if (genre_ == Genre::Data) { std::fputs(" Data ", f); - break; - case Genre::Pointer: + } else if (genre_ == Genre::Pointer) { std::fputs(" Pointer ", f); - break; - case Genre::Allocatable: + } else if (genre_ == Genre::Allocatable) { std::fputs(" Allocatable", f); - break; - case Genre::Automatic: + } else if (genre_ == Genre::Automatic) { std::fputs(" Automatic ", f); - break; - default: + } else { std::fprintf(f, " (bad genre 0x%x)", static_cast(genre_)); - break; } std::fprintf(f, " category %d kind %d rank %d offset 0x%zx\n", category_, kind_, rank_, static_cast(offset_));