[flang] Enable some new warnings, clean up some of their consequences

Original-commit: flang-compiler/f18@b82d1e9ac9
Reviewed-on: https://github.com/flang-compiler/f18/pull/666
Tree-same-pre-rewrite: false
This commit is contained in:
peter klausler 2019-08-15 10:17:31 -07:00
parent 146946d253
commit 73632f5c36
6 changed files with 26 additions and 17 deletions

View File

@ -89,10 +89,14 @@ if(CMAKE_COMPILER_IS_GNUCXX OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --gcc-toolchain=${GCC}")
endif()
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -pedantic")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror=date-time")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wwrite-strings")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wcast-qual")
set(CMAKE_CXX_FLAGS_RELEASE "-O2")
set(CMAKE_CXX_FLAGS_MINSIZEREL "-O2 '-DCHECK=(void)'")
set(CMAKE_CXX_FLAGS_DEBUG "-g -DDEBUGF18")

View File

@ -216,7 +216,7 @@ public:
}
private:
bitsetType bitset_;
bitsetType bitset_{};
};
}

View File

@ -106,29 +106,33 @@ template<typename M> void Walk(Block &x, M &mutator) {
}
template<std::size_t I = 0, typename Func, typename T>
void ForEachInTuple(const T &tuple, Func func) {
if constexpr (I < std::tuple_size_v<T>) {
func(std::get<I>(tuple));
func(std::get<I>(tuple));
if constexpr (I + 1 < std::tuple_size_v<T>) {
ForEachInTuple<I + 1>(tuple, func);
}
}
template<typename V, typename... A>
void Walk(const std::tuple<A...> &x, V &visitor) {
if (visitor.Pre(x)) {
ForEachInTuple(x, [&](const auto &y) { Walk(y, visitor); });
visitor.Post(x);
if (sizeof...(A) > 0) {
if (visitor.Pre(x)) {
ForEachInTuple(x, [&](const auto &y) { Walk(y, visitor); });
visitor.Post(x);
}
}
}
template<std::size_t I = 0, typename Func, typename T>
void ForEachInTuple(T &tuple, Func func) {
if constexpr (I < std::tuple_size_v<T>) {
func(std::get<I>(tuple));
func(std::get<I>(tuple));
if constexpr (I + 1 < std::tuple_size_v<T>) {
ForEachInTuple<I + 1>(tuple, func);
}
}
template<typename M, typename... A> void Walk(std::tuple<A...> &x, M &mutator) {
if (mutator.Pre(x)) {
ForEachInTuple(x, [&](auto &y) { Walk(y, mutator); });
mutator.Post(x);
if (sizeof...(A) > 0) {
if (mutator.Pre(x)) {
ForEachInTuple(x, [&](auto &y) { Walk(y, mutator); });
mutator.Post(x);
}
}
}
template<typename V, typename... A>

View File

@ -961,6 +961,7 @@ static std::int64_t ExpressionValue(const TokenSequence &token,
ExpressionValue(token, operandPrecedence[op], atToken, error)};
left = left != 0 ? right : third;
}
break;
case COMMA: left = right; break;
default: CRASH_NO_CASE;
}

View File

@ -2479,10 +2479,10 @@ private:
// Traverse a std::tuple<>, with an optional separator.
template<std::size_t J = 0, typename T>
void WalkTupleElements(const T &tuple, const char *separator) {
if (J > 0 && J < std::tuple_size_v<T>) {
Word(separator); // this usage dodges "unused parameter" warning
}
if constexpr (J < std::tuple_size_v<T>) {
if (J > 0) {
Word(separator);
}
Walk(std::get<J>(tuple));
WalkTupleElements<J + 1>(tuple, separator);
}

View File

@ -72,7 +72,7 @@ bool IsDerivedTypeFromModule(
bool IsTeamType(const DerivedTypeSpec *);
// Is this derived type either C_PTR or C_FUNPTR from module ISO_C_BINDING
bool IsIsoCType(const DerivedTypeSpec *);
const bool IsEventTypeOrLockType(const DerivedTypeSpec *);
bool IsEventTypeOrLockType(const DerivedTypeSpec *);
// Returns an ultimate component symbol that is a
// coarray or nullptr if there are no such component.
// There is no guarantee regarding which ultimate coarray