[flang-commits] [flang] 4f1037f - [flang][build] Fix build issue reported on recent commit
Peter Klausler via flang-commits
flang-commits at lists.llvm.org
Mon Feb 13 14:24:31 PST 2023
Author: Peter Klausler
Date: 2023-02-13T14:24:18-08:00
New Revision: 4f1037f86a6291c6cd51abdaf29b83e077a49a58
URL: https://github.com/llvm/llvm-project/commit/4f1037f86a6291c6cd51abdaf29b83e077a49a58
DIFF: https://github.com/llvm/llvm-project/commit/4f1037f86a6291c6cd51abdaf29b83e077a49a58.diff
LOG: [flang][build] Fix build issue reported on recent commit
Some compiler (not specified) reported to issue an error on a
"default:" clause in a switch statement whose cases cover all of
the values of an "enum class". Since other compilers/versions
are known to complain in the other direction, change the switch
statement to a cascade of ifs.
Added:
Modified:
flang/lib/Semantics/data-to-inits.cpp
Removed:
################################################################################
diff --git a/flang/lib/Semantics/data-to-inits.cpp b/flang/lib/Semantics/data-to-inits.cpp
index d91a2503a699..52191edbab6e 100644
--- a/flang/lib/Semantics/data-to-inits.cpp
+++ b/flang/lib/Semantics/data-to-inits.cpp
@@ -436,26 +436,25 @@ bool DataInitializationCompiler<DSV>::InitElement(
DescribeElement(), designatorType->AsFortran());
}
auto folded{evaluate::Fold(context, std::move(converted->first))};
- switch (GetImage().Add(
- offsetSymbol.offset(), offsetSymbol.size(), folded, context)) {
- case evaluate::InitialImage::Ok:
+ // Rewritten from a switch() in order to avoid getting complaints
+ // about a missing "default:" from some compilers and complaints
+ // about a redundant "default:" from others.
+ auto status{GetImage().Add(
+ offsetSymbol.offset(), offsetSymbol.size(), folded, context)};
+ if (status == evaluate::InitialImage::Ok) {
return true;
- case evaluate::InitialImage::NotAConstant:
+ } else if (status == evaluate::InitialImage::NotAConstant) {
exprAnalyzer_.Say(
"DATA statement value '%s' for '%s' is not a constant"_err_en_US,
folded.AsFortran(), DescribeElement());
- break;
- case evaluate::InitialImage::OutOfRange:
+ } else if (status == evaluate::InitialImage::OutOfRange) {
OutOfRangeError();
- break;
- case evaluate::InitialImage::SizeMismatch:
+ } else if (status == evaluate::InitialImage::SizeMismatch) {
exprAnalyzer_.Say(
"DATA statement value '%s' for '%s' has the wrong length"_warn_en_US,
folded.AsFortran(), DescribeElement());
- break;
- default:
+ } else {
CHECK(exprAnalyzer_.context().AnyFatalError());
- break;
}
} else {
exprAnalyzer_.context().Say(
More information about the flang-commits
mailing list