[flang] Enable more warnings, deal with fallout

Original-commit: flang-compiler/f18@65c5b485af
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 13:50:27 -07:00
parent e8c453f4ae
commit 10688e0903
26 changed files with 152 additions and 162 deletions

View File

@@ -89,14 +89,13 @@ 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 -pedantic")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
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} -pedantic -Wall -Wextra -Werror")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wcast-qual")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wimplicit-fallthrough")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wdelete-non-virtual-dtor")
set(CMAKE_CXX_FLAGS_RELEASE "-O2")
set(CMAKE_CXX_FLAGS_MINSIZEREL "-O2 '-DCHECK=(void)'")
set(CMAKE_CXX_FLAGS_DEBUG "-g -DDEBUGF18")

View File

@@ -342,8 +342,8 @@ public:
}
}
void Descend(const SpecificIntrinsic &si) {}
void Descend(SpecificIntrinsic &si) {}
void Descend(const SpecificIntrinsic &) {}
void Descend(SpecificIntrinsic &) {}
void Descend(const ProcedureDesignator &p) { Visit(p.u); }
void Descend(ProcedureDesignator &p) { Visit(p.u); }

View File

@@ -2551,7 +2551,7 @@ template<typename A> bool IsInitialDataTarget(const A &) { return false; }
template<typename... A> bool IsInitialDataTarget(const std::variant<A...> &);
bool IsInitialDataTarget(const DataRef &);
template<typename T> bool IsInitialDataTarget(const Expr<T> &);
bool IsInitialDataTarget(const semantics::Symbol &s) { return true; }
bool IsInitialDataTarget(const semantics::Symbol &) { return true; }
bool IsInitialDataTarget(const semantics::Symbol *s) {
return IsInitialDataTarget(*s);
}

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
// Copyright (c) 2018-2019, NVIDIA CORPORATION. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -40,14 +40,15 @@ ValueWithRealFlags<REAL> TimesIntPowerOf(const REAL &factor, const REAL &base,
for (int j{0}; j < nbits; ++j) {
if (absPower.BTEST(j)) {
if (negativePower) {
result.value =
result.value.Divide(squares).AccumulateFlags(result.flags);
result.value = result.value.Divide(squares, rounding)
.AccumulateFlags(result.flags);
} else {
result.value =
result.value.Multiply(squares).AccumulateFlags(result.flags);
result.value = result.value.Multiply(squares, rounding)
.AccumulateFlags(result.flags);
}
}
squares = squares.Multiply(squares).AccumulateFlags(result.flags);
squares =
squares.Multiply(squares, rounding).AccumulateFlags(result.flags);
}
}
return result;

View File

@@ -432,8 +432,7 @@ std::string Real<W, P, IM>::DumpHexadecimal() const {
}
template<typename W, int P, bool IM>
std::ostream &Real<W, P, IM>::AsFortran(
std::ostream &o, int kind, Rounding rounding) const {
std::ostream &Real<W, P, IM>::AsFortran(std::ostream &o, int kind) const {
if (IsNotANumber()) {
o << "(0._" << kind << "/0.)";
} else if (IsInfinite()) {

View File

@@ -364,8 +364,7 @@ public:
// Emits a character representation for an equivalent Fortran constant
// or parenthesized constant expression that produces this value.
std::ostream &AsFortran(
std::ostream &, int kind, Rounding rounding = defaultRounding) const;
std::ostream &AsFortran(std::ostream &, int kind) const;
private:
using Significand = Integer<significandBits>; // no implicit bit

View File

@@ -349,7 +349,7 @@ Shape GetUpperBounds(FoldingContext &context, const NamedEntity &base) {
void GetShapeVisitor::Handle(const Symbol &symbol) {
std::visit(
common::visitors{
[&](const semantics::ObjectEntityDetails &object) {
[&](const semantics::ObjectEntityDetails &) {
Handle(NamedEntity{symbol});
},
[&](const semantics::AssocEntityDetails &assoc) {

View File

@@ -372,17 +372,17 @@ std::optional<Expr<SomeType>> Negation(
[&](Expr<SomeInteger> &&x) { return Package(-std::move(x)); },
[&](Expr<SomeReal> &&x) { return Package(-std::move(x)); },
[&](Expr<SomeComplex> &&x) { return Package(-std::move(x)); },
[&](Expr<SomeCharacter> &&x) {
[&](Expr<SomeCharacter> &&) {
// TODO: defined operator
messages.Say("CHARACTER cannot be negated"_err_en_US);
return NoExpr();
},
[&](Expr<SomeLogical> &&x) {
[&](Expr<SomeLogical> &&) {
// TODO: defined operator
messages.Say("LOGICAL cannot be negated"_err_en_US);
return NoExpr();
},
[&](Expr<SomeDerived> &&x) {
[&](Expr<SomeDerived> &&) {
// TODO: defined operator
messages.Say("Operand cannot be negated"_err_en_US);
return NoExpr();

View File

@@ -698,7 +698,7 @@ public:
return true;
}
template<typename T> void Post(const T &x) {
template<typename T> void Post(const T &) {
if constexpr (!HasSource<T>::value && (UnionTrait<T> || WrapperTrait<T>)) {
EndLineIfNonempty();
} else {
@@ -726,8 +726,7 @@ public:
EndLine();
return true;
}
void Post(const std::int64_t &x) { --indent_; }
void Post(const std::int64_t &) { --indent_; }
bool Pre(const std::uint64_t &x) {
IndentEmptyLine();

View File

@@ -212,7 +212,7 @@ void AllSources::EmitMessage(std::ostream &o,
o << "^\n";
}
},
[&](const CompilerInsertion &ins) { o << message << '\n'; },
[&](const CompilerInsertion &) { o << message << '\n'; },
},
origin.u);
}
@@ -228,7 +228,7 @@ const SourceFile *AllSources::GetSourceFile(
}
return &inc.source;
},
[&](const Macro &mac) {
[&](const Macro &) {
return GetSourceFile(origin.replaces.start(), offset);
},
[offset](const CompilerInsertion &) {

View File

@@ -153,7 +153,7 @@ public:
private:
struct Inclusion {
const SourceFile &source;
bool isModule;
bool isModule{false};
};
struct Module {
const SourceFile &source;

View File

@@ -93,7 +93,7 @@ const CoindexedNamedObject *GetCoindexedNamedObject(
[](const StructureComponent &x) -> const CoindexedNamedObject * {
return GetCoindexedNamedObject(x.base);
},
[](const auto &x) -> const CoindexedNamedObject * { return nullptr; },
[](const auto &) -> const CoindexedNamedObject * { return nullptr; },
},
allocateObject.u);
}

View File

@@ -120,19 +120,19 @@ public:
void Unparse(const DeclarationTypeSpec::Record &x) {
Word("RECORD/"), Walk(x.v), Put('/');
}
void Before(const IntrinsicTypeSpec::Real &x) { // R704
void Before(const IntrinsicTypeSpec::Real &) { // R704
Word("REAL");
}
void Before(const IntrinsicTypeSpec::Complex &x) { Word("COMPLEX"); }
void Before(const IntrinsicTypeSpec::Complex &) { Word("COMPLEX"); }
void Post(const IntrinsicTypeSpec::DoublePrecision &) {
Word("DOUBLE PRECISION");
}
void Before(const IntrinsicTypeSpec::Character &x) { Word("CHARACTER"); }
void Before(const IntrinsicTypeSpec::Logical &x) { Word("LOGICAL"); }
void Before(const IntrinsicTypeSpec::Character &) { Word("CHARACTER"); }
void Before(const IntrinsicTypeSpec::Logical &) { Word("LOGICAL"); }
void Post(const IntrinsicTypeSpec::DoubleComplex &) {
Word("DOUBLE COMPLEX");
}
void Before(const IntegerTypeSpec &x) { // R705
void Before(const IntegerTypeSpec &) { // R705
Word("INTEGER");
}
void Unparse(const KindSelector &x) { // R706
@@ -212,7 +212,7 @@ public:
Walk("(", std::get<std::list<Name>>(x.t), ", ", ")");
Indent();
}
void Unparse(const Abstract &x) { // R728, &c.
void Unparse(const Abstract &) { // R728, &c.
Word("ABSTRACT");
}
void Post(const TypeAttrSpec::BindC &) { Word("BIND(C)"); }
@@ -222,7 +222,7 @@ public:
void Unparse(const EndTypeStmt &x) { // R730
Outdent(), Word("END TYPE"), Walk(" ", x.v);
}
void Unparse(const SequenceStmt &x) { // R731
void Unparse(const SequenceStmt &) { // R731
Word("SEQUENCE");
}
void Unparse(const TypeParamDefStmt &x) { // R732
@@ -254,11 +254,11 @@ public:
}
Put(' '), Walk(decls, ", ");
}
void Unparse(const Allocatable &x) { // R738
void Unparse(const Allocatable &) { // R738
Word("ALLOCATABLE");
}
void Unparse(const Pointer &x) { Word("POINTER"); }
void Unparse(const Contiguous &x) { Word("CONTIGUOUS"); }
void Unparse(const Pointer &) { Word("POINTER"); }
void Unparse(const Contiguous &) { Word("CONTIGUOUS"); }
void Before(const ComponentAttrSpec &x) {
std::visit(
common::visitors{
@@ -298,7 +298,7 @@ public:
Walk(", ", std::get<std::list<ProcComponentAttrSpec>>(x.t), ", ");
Put(" :: "), Walk(std::get<std::list<ProcDecl>>(x.t), ", ");
}
void Unparse(const NoPass &x) { // R742
void Unparse(const NoPass &) { // R742
Word("NOPASS");
}
void Unparse(const Pass &x) { Word("PASS"), Walk("(", x.v, ")"); }
@@ -314,7 +314,7 @@ public:
},
x.u);
}
void Unparse(const PrivateStmt &x) { // R745
void Unparse(const PrivateStmt &) { // R745
Word("PRIVATE");
}
void Unparse(const TypeBoundProcedureStmt::WithoutInterface &x) { // R749
@@ -453,8 +453,8 @@ public:
void Before(const AttrSpec &x) { // R802
std::visit(
common::visitors{
[&](const CoarraySpec &y) { Word("CODIMENSION["); },
[&](const ArraySpec &y) { Word("DIMENSION("); },
[&](const CoarraySpec &) { Word("CODIMENSION["); },
[&](const ArraySpec &) { Word("DIMENSION("); },
[](const auto &) {},
},
x.u);
@@ -462,8 +462,8 @@ public:
void Post(const AttrSpec &x) {
std::visit(
common::visitors{
[&](const CoarraySpec &y) { Put(']'); },
[&](const ArraySpec &y) { Put(')'); },
[&](const CoarraySpec &) { Put(']'); },
[&](const ArraySpec &) { Put(')'); },
[](const auto &) {},
},
x.u);
@@ -475,7 +475,7 @@ public:
Walk("*", std::get<std::optional<CharLength>>(x.t));
Walk(std::get<std::optional<Initialization>>(x.t));
}
void Unparse(const NullInit &x) { // R806
void Unparse(const NullInit &) { // R806
Word("NULL()");
}
void Unparse(const LanguageBindingSpec &x) { // R808 & R1528
@@ -813,9 +813,9 @@ public:
}
}
void Unparse(const Expr::Parentheses &x) { Put('('), Walk(x.v), Put(')'); }
void Before(const Expr::UnaryPlus &x) { Put("+"); }
void Before(const Expr::Negate &x) { Put("-"); }
void Before(const Expr::NOT &x) { Word(".NOT."); }
void Before(const Expr::UnaryPlus &) { Put("+"); }
void Before(const Expr::Negate &) { Put("-"); }
void Before(const Expr::NOT &) { Word(".NOT."); }
void Unparse(const Expr::PercentLoc &x) {
Word("%LOC("), Walk(x.v), Put(')');
}
@@ -974,7 +974,7 @@ public:
Put(':'), Walk(std::get<2>(x.t));
Walk(":", std::get<std::optional<ScalarIntExpr>>(x.t));
}
void Before(const LoopControl::Concurrent &x) { // R1129
void Before(const LoopControl::Concurrent &) { // R1129
Word("CONCURRENT");
}
void Unparse(const LocalitySpec::Local &x) {
@@ -986,7 +986,7 @@ public:
void Unparse(const LocalitySpec::Shared &x) {
Word("SHARED("), Walk(x.v, ", "), Put(')');
}
void Post(const LocalitySpec::DefaultNone &x) { Word("DEFAULT(NONE)"); }
void Post(const LocalitySpec::DefaultNone &) { Word("DEFAULT(NONE)"); }
void Unparse(const EndDoStmt &x) { // R1132
Word("END DO"), Walk(" ", x.v);
}
@@ -1078,13 +1078,13 @@ public:
void Unparse(const ExitStmt &x) { // R1156
Word("EXIT"), Walk(" ", x.v);
}
void Before(const GotoStmt &x) { // R1157
void Before(const GotoStmt &) { // R1157
Word("GO TO ");
}
void Unparse(const ComputedGotoStmt &x) { // R1158
Word("GO TO ("), Walk(x.t, "), ");
}
void Unparse(const ContinueStmt &x) { // R1159
void Unparse(const ContinueStmt &) { // R1159
Word("CONTINUE");
}
void Unparse(const StopStmt &x) { // R1160, R1161
@@ -1094,7 +1094,7 @@ public:
Word("STOP"), Walk(" ", std::get<std::optional<StopCode>>(x.t));
Walk(", QUIET=", std::get<std::optional<ScalarLogicalExpr>>(x.t));
}
void Unparse(const FailImageStmt &x) { // R1163
void Unparse(const FailImageStmt &) { // R1163
Word("FAIL IMAGE");
}
void Unparse(const SyncAllStmt &x) { // R1164
@@ -1119,7 +1119,7 @@ public:
void Before(const EventWaitStmt::EventWaitSpec &x) { // R1173, R1174
std::visit(
common::visitors{
[&](const ScalarIntExpr &x) { Word("UNTIL_COUNT="); },
[&](const ScalarIntExpr &) { Word("UNTIL_COUNT="); },
[](const StatOrErrmsg &) {},
},
x.u);
@@ -1138,7 +1138,7 @@ public:
void Before(const FormTeamStmt::FormTeamSpec &x) { // R1176, R1178
std::visit(
common::visitors{
[&](const ScalarIntExpr &x) { Word("NEW_INDEX="); },
[&](const ScalarIntExpr &) { Word("NEW_INDEX="); },
[](const StatOrErrmsg &) {},
},
x.u);
@@ -1152,7 +1152,7 @@ public:
std::visit(
common::visitors{
[&](const ScalarLogicalVariable &) { Word("ACQUIRED_LOCK="); },
[](const StatOrErrmsg &y) {},
[](const StatOrErrmsg &) {},
},
x.u);
}
@@ -1520,7 +1520,7 @@ public:
Indent();
}
}
void Before(const ProgramStmt &x) { // R1402
void Before(const ProgramStmt &) { // R1402
Word("PROGRAM "), Indent();
}
void Unparse(const EndProgramStmt &x) { // R1403
@@ -1592,7 +1592,7 @@ public:
void Before(const GenericSpec &x) { // R1508, R1509
std::visit(
common::visitors{
[&](const DefinedOperator &x) { Word("OPERATOR("); },
[&](const DefinedOperator &) { Word("OPERATOR("); },
[&](const GenericSpec::Assignment &) { Word("ASSIGNMENT(=)"); },
[&](const GenericSpec::ReadFormatted &) {
Word("READ(FORMATTED)");
@@ -1613,7 +1613,7 @@ public:
void Post(const GenericSpec &x) {
std::visit(
common::visitors{
[&](const DefinedOperator &x) { Put(')'); },
[&](const DefinedOperator &) { Put(')'); },
[](const auto &) {},
},
x.u);
@@ -1720,7 +1720,7 @@ public:
void Unparse(const ReturnStmt &x) { // R1542
Word("RETURN"), Walk(" ", x.v);
}
void Unparse(const ContainsStmt &x) { // R1543
void Unparse(const ContainsStmt &) { // R1543
Outdent();
Word("CONTAINS");
Indent();
@@ -1761,7 +1761,7 @@ public:
const char *slash{isCommon ? "/" : ""};
Put(slash), Walk(std::get<Designator>(x.t)), Put(slash);
}
void Unparse(const OmpMapType::Always &x) { Word("ALWAYS,"); }
void Unparse(const OmpMapType::Always &) { Word("ALWAYS,"); }
void Unparse(const OmpMapClause &x) {
Word("MAP(");
Walk(std::get<std::optional<OmpMapType>>(x.t), ":");
@@ -1826,7 +1826,7 @@ public:
bool Pre(const OmpDependClause &x) {
return std::visit(
common::visitors{
[&](const OmpDependClause::Source &y) {
[&](const OmpDependClause::Source &) {
Word("DEPEND(SOURCE)");
return false;
},
@@ -1836,33 +1836,33 @@ public:
Put(")");
return false;
},
[&](const OmpDependClause::InOut &y) {
[&](const OmpDependClause::InOut &) {
Word("DEPEND");
return true;
},
},
x.u);
}
bool Pre(const OmpDefaultClause &x) {
bool Pre(const OmpDefaultClause &) {
Word("DEFAULT(");
return true;
}
void Post(const OmpDefaultClause &x) { Put(")"); }
bool Pre(const OmpProcBindClause &x) {
void Post(const OmpDefaultClause &) { Put(")"); }
bool Pre(const OmpProcBindClause &) {
Word("PROC_BIND(");
return true;
}
void Post(const OmpProcBindClause &x) { Put(")"); }
void Before(const OmpClause::Defaultmap &x) {
void Post(const OmpProcBindClause &) { Put(")"); }
void Before(const OmpClause::Defaultmap &) {
Word("DEFAULTMAP(TOFROM:SCALAR)");
}
void Before(const OmpClause::Inbranch &x) { Word("INBRANCH"); }
void Before(const OmpClause::Mergeable &x) { Word("MERGEABLE"); }
void Before(const OmpClause::Nogroup &x) { Word("NOGROUP"); }
void Before(const OmpClause::Notinbranch &x) { Word("NOTINBRANCH"); }
void Before(const OmpClause::Untied &x) { Word("UNTIED"); }
void Before(const OmpClause::Threads &x) { Word("THREADS"); }
void Before(const OmpClause::Simd &x) { Word("SIMD"); }
void Before(const OmpClause::Inbranch &) { Word("INBRANCH"); }
void Before(const OmpClause::Mergeable &) { Word("MERGEABLE"); }
void Before(const OmpClause::Nogroup &) { Word("NOGROUP"); }
void Before(const OmpClause::Notinbranch &) { Word("NOTINBRANCH"); }
void Before(const OmpClause::Untied &) { Word("UNTIED"); }
void Before(const OmpClause::Threads &) { Word("THREADS"); }
void Before(const OmpClause::Simd &) { Word("SIMD"); }
void Unparse(const OmpNowait &) { Word("NOWAIT"); }
void Unparse(const OmpClause::Collapse &x) {
Word("COLLAPSE(");
@@ -2223,7 +2223,7 @@ public:
Word("!$OMP ");
return std::visit(
common::visitors{
[&](const OpenMPDeclareReductionConstruct &y) {
[&](const OpenMPDeclareReductionConstruct &) {
Word("DECLARE REDUCTION ");
return true;
},
@@ -2235,22 +2235,22 @@ public:
EndOpenMP();
return false;
},
[&](const OpenMPDeclareTargetConstruct &y) {
[&](const OpenMPDeclareTargetConstruct &) {
Word("DECLARE TARGET ");
return true;
},
[&](const OpenMPThreadprivate &y) {
[&](const OpenMPThreadprivate &) {
Word("THREADPRIVATE (");
return true;
},
},
x.u);
}
void Post(const OpenMPDeclarativeConstruct &x) {
void Post(const OpenMPDeclarativeConstruct &) {
Put("\n");
EndOpenMP();
}
void Post(const OpenMPThreadprivate &x) {
void Post(const OpenMPThreadprivate &) {
Put(")\n");
EndOpenMP();
}

View File

@@ -41,9 +41,8 @@ void CheckPointerAssignment(parser::ContextualMessages &messages,
symbol.name());
}
void CheckPointerAssignment(parser::ContextualMessages &messages,
const IntrinsicProcTable &intrinsics, const Symbol &lhs,
const NullPointer &f) {
void CheckPointerAssignment(parser::ContextualMessages &,
const IntrinsicProcTable &, const Symbol &, const NullPointer &) {
// LHS = NULL() without MOLD=; this is always fine
}
@@ -111,8 +110,7 @@ void CheckPointerAssignment(parser::ContextualMessages &messages,
template<typename T>
void CheckPointerAssignment(parser::ContextualMessages &messages,
const IntrinsicProcTable &intrinsics, const Symbol &lhs,
const Designator<T> &d) {
const IntrinsicProcTable &, const Symbol &lhs, const Designator<T> &d) {
const Symbol *last{d.GetLastSymbol()};
const Symbol *base{d.GetBaseObject().symbol()};
if (last != nullptr && base != nullptr) {
@@ -339,7 +337,7 @@ private:
namespace Fortran::semantics {
void AssignmentContext::Analyze(const parser::AssignmentStmt &stmt) {
void AssignmentContext::Analyze(const parser::AssignmentStmt &) {
if (forall_ != nullptr) {
// TODO: Warn if some name in forall_->activeNames or its outer
// contexts does not appear on LHS
@@ -348,7 +346,7 @@ void AssignmentContext::Analyze(const parser::AssignmentStmt &stmt) {
// (re)allocation of LHS array when unallocated or nonconformable)
}
void AssignmentContext::Analyze(const parser::PointerAssignmentStmt &stmt) {
void AssignmentContext::Analyze(const parser::PointerAssignmentStmt &) {
CHECK(!where_);
if (forall_ != nullptr) {
// TODO: Warn if some name in forall_->activeNames or its outer

View File

@@ -138,14 +138,14 @@ static std::optional<AllocateCheckerInfo> CheckAllocateOptions(
[&](const parser::StatOrErrmsg &statOrErr) {
std::visit(
common::visitors{
[&](const parser::StatVariable &statVariable) {
[&](const parser::StatVariable &) {
if (info.gotStat) { // C943
context.Say(
"STAT may not be duplicated in a ALLOCATE statement"_err_en_US);
}
info.gotStat = true;
},
[&](const parser::MsgVariable &msgVariable) {
[&](const parser::MsgVariable &) {
if (info.gotMsg) { // C943
context.Say(
"ERRMSG may not be duplicated in a ALLOCATE statement"_err_en_US);

View File

@@ -55,14 +55,14 @@ void DeallocateChecker::Leave(const parser::DeallocateStmt &deallocateStmt) {
std::get<std::list<parser::StatOrErrmsg>>(deallocateStmt.t)) {
std::visit(
common::visitors{
[&](const parser::StatVariable &statVariable) {
[&](const parser::StatVariable &) {
if (gotStat) {
context_.Say(
"STAT may not be duplicated in a DEALLOCATE statement"_err_en_US);
}
gotStat = true;
},
[&](const parser::MsgVariable &msgVariable) {
[&](const parser::MsgVariable &) {
if (gotMsg) {
context_.Say(
"ERRMSG may not be duplicated in a DEALLOCATE statement"_err_en_US);

View File

@@ -148,19 +148,19 @@ void IoChecker::Enter(const parser::ConnectSpec::Recl &spec) {
}
}
void IoChecker::Enter(const parser::EndLabel &spec) {
void IoChecker::Enter(const parser::EndLabel &) {
SetSpecifier(IoSpecKind::End);
}
void IoChecker::Enter(const parser::EorLabel &spec) {
void IoChecker::Enter(const parser::EorLabel &) {
SetSpecifier(IoSpecKind::Eor);
}
void IoChecker::Enter(const parser::ErrLabel &spec) {
void IoChecker::Enter(const parser::ErrLabel &) {
SetSpecifier(IoSpecKind::Err);
}
void IoChecker::Enter(const parser::FileUnitNumber &spec) {
void IoChecker::Enter(const parser::FileUnitNumber &) {
SetSpecifier(IoSpecKind::Unit);
flags_.set(Flag::NumberUnit);
}
@@ -217,9 +217,7 @@ void IoChecker::Enter(const parser::Format &spec) {
spec.u);
}
void IoChecker::Enter(const parser::IdExpr &spec) {
SetSpecifier(IoSpecKind::Id);
}
void IoChecker::Enter(const parser::IdExpr &) { SetSpecifier(IoSpecKind::Id); }
void IoChecker::Enter(const parser::IdVariable &spec) {
SetSpecifier(IoSpecKind::Id);
@@ -363,15 +361,15 @@ void IoChecker::Enter(const parser::IoControlSpec::CharExpr &spec) {
}
}
void IoChecker::Enter(const parser::IoControlSpec::Pos &spec) {
void IoChecker::Enter(const parser::IoControlSpec::Pos &) {
SetSpecifier(IoSpecKind::Pos);
}
void IoChecker::Enter(const parser::IoControlSpec::Rec &spec) {
void IoChecker::Enter(const parser::IoControlSpec::Rec &) {
SetSpecifier(IoSpecKind::Rec);
}
void IoChecker::Enter(const parser::IoControlSpec::Size &spec) {
void IoChecker::Enter(const parser::IoControlSpec::Size &) {
SetSpecifier(IoSpecKind::Size);
}
@@ -393,11 +391,11 @@ void IoChecker::Enter(const parser::IoUnit &spec) {
}
}
void IoChecker::Enter(const parser::MsgVariable &spec) {
void IoChecker::Enter(const parser::MsgVariable &) {
SetSpecifier(IoSpecKind::Iomsg);
}
void IoChecker::Enter(const parser::OutputItem &spec) {
void IoChecker::Enter(const parser::OutputItem &) {
flags_.set(Flag::DataList);
// TODO: C1233 - output item must not be a procedure pointer
}
@@ -426,29 +424,29 @@ void IoChecker::Enter(const parser::StatusExpr &spec) {
}
}
void IoChecker::Enter(const parser::StatVariable &spec) {
void IoChecker::Enter(const parser::StatVariable &) {
SetSpecifier(IoSpecKind::Iostat);
}
void IoChecker::Leave(const parser::BackspaceStmt &stmt) {
void IoChecker::Leave(const parser::BackspaceStmt &) {
CheckForRequiredSpecifier(
flags_.test(Flag::NumberUnit), "UNIT number"); // C1240
stmt_ = IoStmtKind::None;
}
void IoChecker::Leave(const parser::CloseStmt &stmt) {
void IoChecker::Leave(const parser::CloseStmt &) {
CheckForRequiredSpecifier(
flags_.test(Flag::NumberUnit), "UNIT number"); // C1208
stmt_ = IoStmtKind::None;
}
void IoChecker::Leave(const parser::EndfileStmt &stmt) {
void IoChecker::Leave(const parser::EndfileStmt &) {
CheckForRequiredSpecifier(
flags_.test(Flag::NumberUnit), "UNIT number"); // C1240
stmt_ = IoStmtKind::None;
}
void IoChecker::Leave(const parser::FlushStmt &stmt) {
void IoChecker::Leave(const parser::FlushStmt &) {
CheckForRequiredSpecifier(
flags_.test(Flag::NumberUnit), "UNIT number"); // C1243
stmt_ = IoStmtKind::None;
@@ -466,7 +464,7 @@ void IoChecker::Leave(const parser::InquireStmt &stmt) {
stmt_ = IoStmtKind::None;
}
void IoChecker::Leave(const parser::OpenStmt &stmt) {
void IoChecker::Leave(const parser::OpenStmt &) {
CheckForRequiredSpecifier(specifierSet_.test(IoSpecKind::Unit) ||
specifierSet_.test(IoSpecKind::Newunit),
"UNIT or NEWUNIT"); // C1204, C1205
@@ -498,11 +496,9 @@ void IoChecker::Leave(const parser::OpenStmt &stmt) {
stmt_ = IoStmtKind::None;
}
void IoChecker::Leave(const parser::PrintStmt &stmt) {
stmt_ = IoStmtKind::None;
}
void IoChecker::Leave(const parser::PrintStmt &) { stmt_ = IoStmtKind::None; }
void IoChecker::Leave(const parser::ReadStmt &stmt) {
void IoChecker::Leave(const parser::ReadStmt &) {
if (!flags_.test(Flag::IoControlList)) {
return;
}
@@ -520,19 +516,19 @@ void IoChecker::Leave(const parser::ReadStmt &stmt) {
stmt_ = IoStmtKind::None;
}
void IoChecker::Leave(const parser::RewindStmt &stmt) {
void IoChecker::Leave(const parser::RewindStmt &) {
CheckForRequiredSpecifier(
flags_.test(Flag::NumberUnit), "UNIT number"); // C1240
stmt_ = IoStmtKind::None;
}
void IoChecker::Leave(const parser::WaitStmt &stmt) {
void IoChecker::Leave(const parser::WaitStmt &) {
CheckForRequiredSpecifier(
flags_.test(Flag::NumberUnit), "UNIT number"); // C1237
stmt_ = IoStmtKind::None;
}
void IoChecker::Leave(const parser::WriteStmt &stmt) {
void IoChecker::Leave(const parser::WriteStmt &) {
LeaveReadWrite();
CheckForProhibitedSpecifier(IoSpecKind::Blank); // C1213
CheckForProhibitedSpecifier(IoSpecKind::End); // C1213

View File

@@ -65,7 +65,7 @@ void OmpStructureChecker::CheckAllowed(OmpClause type) {
SetContextClauseInfo(type);
}
void OmpStructureChecker::Enter(const parser::OpenMPConstruct &x) {
void OmpStructureChecker::Enter(const parser::OpenMPConstruct &) {
// 2.8.1 TODO: Simd Construct with Ordered Construct Nesting check
}

View File

@@ -909,7 +909,7 @@ MaybeExpr ExpressionAnalyzer::Analyze(const parser::StructureComponent &sc) {
return std::nullopt;
}
MaybeExpr ExpressionAnalyzer::Analyze(const parser::CoindexedNamedObject &co) {
MaybeExpr ExpressionAnalyzer::Analyze(const parser::CoindexedNamedObject &) {
Say("TODO: CoindexedNamedObject unimplemented"_err_en_US);
return std::nullopt;
}

View File

@@ -102,7 +102,7 @@ ProgramTree ProgramTree::Build(const parser::Submodule &x) {
return BuildModuleTree(name, x).set_stmt(stmt).set_endStmt(end);
}
ProgramTree ProgramTree::Build(const parser::BlockData &x) {
ProgramTree ProgramTree::Build(const parser::BlockData &) {
DIE("BlockData not yet implemented");
}

View File

@@ -822,8 +822,8 @@ LabeledStatementInfoTuplePOD GetLabel(
// 11.1.7.3
void CheckBranchesIntoDoBody(const SourceStmtList &branches,
const TargetStmtMap &labels, const std::vector<ProxyForScope> &scopes,
const IndexList &loopBodies, SemanticsContext &context) {
const TargetStmtMap &labels, const IndexList &loopBodies,
SemanticsContext &context) {
for (const auto branch : branches) {
const auto &label{branch.parserLabel};
auto branchTarget{GetLabel(labels, label)};
@@ -922,7 +922,7 @@ void CheckLabelDoConstraints(const SourceStmtList &dos,
}
}
CheckBranchesIntoDoBody(branches, labels, scopes, loopBodies, context);
CheckBranchesIntoDoBody(branches, labels, loopBodies, context);
CheckDoNesting(loopBodies, context);
}

View File

@@ -123,19 +123,19 @@ void GenericSpecInfo::Analyze(const parser::GenericSpec &x) {
},
y.u);
},
[&](const parser::GenericSpec::Assignment &y) {
[&](const parser::GenericSpec::Assignment &) {
return GenericKind::Assignment;
},
[&](const parser::GenericSpec::ReadFormatted &y) {
[&](const parser::GenericSpec::ReadFormatted &) {
return GenericKind::ReadFormatted;
},
[&](const parser::GenericSpec::ReadUnformatted &y) {
[&](const parser::GenericSpec::ReadUnformatted &) {
return GenericKind::ReadUnformatted;
},
[&](const parser::GenericSpec::WriteFormatted &y) {
[&](const parser::GenericSpec::WriteFormatted &) {
return GenericKind::WriteFormatted;
},
[&](const parser::GenericSpec::WriteUnformatted &y) {
[&](const parser::GenericSpec::WriteUnformatted &) {
return GenericKind::WriteUnformatted;
},
},
@@ -472,7 +472,7 @@ bool EquivalenceSets::CheckDataRef(
for (const auto &subscript : elem.value().subscripts) {
ok &= std::visit(
common::visitors{
[&](const parser::SubscriptTriplet &y) {
[&](const parser::SubscriptTriplet &) {
context_.Say(source, // C924, R872
"Array section '%s' is not allowed in an equivalence set"_err_en_US,
source);

View File

@@ -701,7 +701,7 @@ public:
return true;
}
void Post(const parser::AllocatableStmt &) { objectDeclAttr_ = std::nullopt; }
bool Pre(const parser::TargetStmt &x) {
bool Pre(const parser::TargetStmt &) {
objectDeclAttr_ = Attr::TARGET;
return true;
}
@@ -724,13 +724,13 @@ public:
bool Pre(const parser::DeclarationTypeSpec::Record &);
void Post(const parser::DerivedTypeSpec &);
bool Pre(const parser::DerivedTypeDef &);
bool Pre(const parser::DerivedTypeStmt &x);
void Post(const parser::DerivedTypeStmt &x);
bool Pre(const parser::TypeParamDefStmt &x) { return BeginDecl(); }
bool Pre(const parser::DerivedTypeStmt &);
void Post(const parser::DerivedTypeStmt &);
bool Pre(const parser::TypeParamDefStmt &) { return BeginDecl(); }
void Post(const parser::TypeParamDefStmt &);
bool Pre(const parser::TypeAttrSpec::Extends &x);
bool Pre(const parser::PrivateStmt &x);
bool Pre(const parser::SequenceStmt &x);
bool Pre(const parser::TypeAttrSpec::Extends &);
bool Pre(const parser::PrivateStmt &);
bool Pre(const parser::SequenceStmt &);
bool Pre(const parser::ComponentDefStmt &) { return BeginDecl(); }
void Post(const parser::ComponentDefStmt &) { EndDecl(); }
void Post(const parser::ComponentDecl &);
@@ -951,7 +951,7 @@ public:
bool Pre(const parser::WhereConstructStmt &x) { return CheckDef(x.t); }
bool Pre(const parser::ForallConstructStmt &x) { return CheckDef(x.t); }
bool Pre(const parser::CriticalStmt &x) { return CheckDef(x.t); }
bool Pre(const parser::LabelDoStmt &x) {
bool Pre(const parser::LabelDoStmt &) {
return false; // error recovery
}
bool Pre(const parser::NonLabelDoStmt &x) { return CheckDef(x.t); }
@@ -1382,17 +1382,17 @@ Message &MessageHandler::Say(const SourceName &name, MessageFixedText &&msg) {
// ImplicitRulesVisitor implementation
void ImplicitRulesVisitor::Post(const parser::ParameterStmt &x) {
void ImplicitRulesVisitor::Post(const parser::ParameterStmt &) {
prevParameterStmt_ = currStmtSource();
}
bool ImplicitRulesVisitor::Pre(const parser::ImplicitStmt &x) {
bool result{std::visit(
common::visitors{
[&](const std::list<ImplicitNoneNameSpec> &x) {
return HandleImplicitNone(x);
[&](const std::list<ImplicitNoneNameSpec> &y) {
return HandleImplicitNone(y);
},
[&](const std::list<parser::ImplicitSpec> &x) {
[&](const std::list<parser::ImplicitSpec> &) {
if (prevImplicitNoneType_) {
Say("IMPLICIT statement after IMPLICIT NONE or "
"IMPLICIT NONE(TYPE) statement"_err_en_US);
@@ -2126,7 +2126,7 @@ bool InterfaceVisitor::Pre(const parser::ProcedureStmt &x) {
return false;
}
bool InterfaceVisitor::Pre(const parser::GenericStmt &x) {
bool InterfaceVisitor::Pre(const parser::GenericStmt &) {
genericInfo_.emplace(/*isInterface*/ false);
return true;
}
@@ -2331,7 +2331,7 @@ void InterfaceVisitor::CheckSpecificsAreDistinguishable(
// SubprogramVisitor implementation
void SubprogramVisitor::Post(const parser::StmtFunctionStmt &x) {
void SubprogramVisitor::Post(const parser::StmtFunctionStmt &) {
if (badStmtFuncFound_) {
return; // This wasn't really a stmt function so no scope was created
}
@@ -2424,10 +2424,10 @@ void SubprogramVisitor::Post(const parser::InterfaceBody::Function &) {
EndSubprogram();
}
bool SubprogramVisitor::Pre(const parser::SubroutineStmt &stmt) {
bool SubprogramVisitor::Pre(const parser::SubroutineStmt &) {
return BeginAttrs();
}
bool SubprogramVisitor::Pre(const parser::FunctionStmt &stmt) {
bool SubprogramVisitor::Pre(const parser::FunctionStmt &) {
return BeginAttrs();
}
@@ -2970,7 +2970,7 @@ void DeclarationVisitor::Post(const parser::IntrinsicTypeSpec::Complex &x) {
void DeclarationVisitor::Post(const parser::IntrinsicTypeSpec::Logical &x) {
SetDeclTypeSpec(MakeLogicalType(x.kind));
}
void DeclarationVisitor::Post(const parser::IntrinsicTypeSpec::Character &x) {
void DeclarationVisitor::Post(const parser::IntrinsicTypeSpec::Character &) {
if (!charInfo_.length) {
charInfo_.length = ParamValue{1, common::TypeParamAttr::Len};
}
@@ -3014,12 +3014,12 @@ bool DeclarationVisitor::Pre(const parser::KindParam &x) {
return false;
}
bool DeclarationVisitor::Pre(const parser::DeclarationTypeSpec::Type &x) {
bool DeclarationVisitor::Pre(const parser::DeclarationTypeSpec::Type &) {
CHECK(GetDeclTypeSpecCategory() == DeclTypeSpec::Category::TypeDerived);
return true;
}
bool DeclarationVisitor::Pre(const parser::DeclarationTypeSpec::Class &x) {
bool DeclarationVisitor::Pre(const parser::DeclarationTypeSpec::Class &) {
SetDeclTypeSpecCategory(DeclTypeSpec::Category::ClassDerived);
return true;
}
@@ -3202,7 +3202,7 @@ bool DeclarationVisitor::Pre(const parser::DerivedTypeDef &x) {
PopScope();
return false;
}
bool DeclarationVisitor::Pre(const parser::DerivedTypeStmt &x) {
bool DeclarationVisitor::Pre(const parser::DerivedTypeStmt &) {
return BeginAttrs();
}
void DeclarationVisitor::Post(const parser::DerivedTypeStmt &x) {
@@ -3269,7 +3269,7 @@ bool DeclarationVisitor::Pre(const parser::TypeAttrSpec::Extends &x) {
return false;
}
bool DeclarationVisitor::Pre(const parser::PrivateStmt &x) {
bool DeclarationVisitor::Pre(const parser::PrivateStmt &) {
if (!currScope().parent().IsModule()) {
Say("PRIVATE is only allowed in a derived type that is"
" in a module"_err_en_US); // C766
@@ -3283,7 +3283,7 @@ bool DeclarationVisitor::Pre(const parser::PrivateStmt &x) {
}
return false;
}
bool DeclarationVisitor::Pre(const parser::SequenceStmt &x) {
bool DeclarationVisitor::Pre(const parser::SequenceStmt &) {
derivedTypeInfo_.sequence = true;
return false;
}
@@ -3366,7 +3366,7 @@ void DeclarationVisitor::Post(const parser::ProcDecl &x) {
}
}
bool DeclarationVisitor::Pre(const parser::TypeBoundProcedurePart &x) {
bool DeclarationVisitor::Pre(const parser::TypeBoundProcedurePart &) {
derivedTypeInfo_.sawContains = true;
return true;
}
@@ -3615,7 +3615,7 @@ void DeclarationVisitor::Post(const parser::CommonStmt::Block &) {
commonBlockInfo_.curr = nullptr;
}
bool DeclarationVisitor::Pre(const parser::CommonBlockObject &x) {
bool DeclarationVisitor::Pre(const parser::CommonBlockObject &) {
BeginArraySpec();
return true;
}
@@ -4940,8 +4940,7 @@ void DeclarationVisitor::Initialization(const parser::Name &name,
details->set_init(std::move(*expr));
}
},
[&](const std::list<common::Indirection<parser::DataStmtValue>>
&list) {
[&](const std::list<common::Indirection<parser::DataStmtValue>> &) {
if (inComponentDecl) {
Say(name,
"Component '%s' initialized with DATA statement values"_err_en_US);
@@ -5209,7 +5208,7 @@ void ResolveNamesVisitor::PreSpecificationConstruct(
const parser::SpecificationConstruct &spec) {
std::visit(
common::visitors{
[&](const Indirection<parser::DerivedTypeDef> &y) {},
[&](const Indirection<parser::DerivedTypeDef> &) {},
[&](const parser::Statement<Indirection<parser::GenericStmt>> &y) {
CreateGeneric(std::get<parser::GenericSpec>(y.statement.value().t));
},

View File

@@ -386,8 +386,8 @@ std::ostream &operator<<(std::ostream &os, const Details &details) {
os << DetailsToString(details);
std::visit(
common::visitors{
[&](const UnknownDetails &x) {},
[&](const MainProgramDetails &x) {},
[&](const UnknownDetails &) {},
[&](const MainProgramDetails &) {},
[&](const ModuleDetails &x) {
if (x.isSubmodule()) {
os << " (";

View File

@@ -146,7 +146,7 @@ bool IsFunction(const Symbol &symbol) {
return std::visit(
common::visitors{
[](const SubprogramDetails &x) { return x.isFunction(); },
[&](const SubprogramNameDetails &x) {
[&](const SubprogramNameDetails &) {
return symbol.test(Symbol::Flag::Function);
},
[](const ProcEntityDetails &x) {

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
// Copyright (c) 2018-2019, NVIDIA CORPORATION. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -163,7 +163,7 @@ template<typename R> void basicTests(int rm, Rounding rounding) {
TEST(ivf.flags.empty())(ldesc);
MATCH(x, ivf.value.ToUInt64())(ldesc);
std::stringstream ss;
vr.value.AsFortran(ss, kind, rounding);
vr.value.AsFortran(ss, kind);
std::string decimal{ss.str()};
const char *p{decimal.data()};
MATCH(x, static_cast<std::uint64_t>(std::stold(decimal)))(ldesc);
@@ -406,7 +406,7 @@ void subsetTests(int pass, Rounding rounding, std::uint32_t opds) {
static constexpr int kind{REAL::bits / 8};
std::stringstream ss, css;
x.AsFortran(ss, kind, rounding);
x.AsFortran(ss, kind);
std::string s{ss.str()};
if (IsNaN(rj)) {
css << "(0._" << kind << "/0.)";