Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions flang/include/flang/Semantics/scope.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ class SemanticsContext;
struct EquivalenceObject {
EquivalenceObject(Symbol &symbol, std::vector<ConstantSubscript> subscripts,
std::optional<ConstantSubscript> substringStart, parser::CharBlock source)
: symbol{symbol}, subscripts{subscripts},
substringStart{substringStart}, source{source} {}
: symbol{symbol}, subscripts{subscripts}, substringStart{substringStart},
source{source} {}
explicit EquivalenceObject(Symbol &symbol)
: symbol{symbol}, source{symbol.name()} {}

Expand Down
2 changes: 1 addition & 1 deletion flang/include/flang/Semantics/symbol.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace Fortran::parser {
struct Expr;
struct OpenMPDeclareReductionConstruct;
struct OmpMetadirectiveDirective;
}
} // namespace Fortran::parser

namespace Fortran::semantics {

Expand Down
8 changes: 4 additions & 4 deletions flang/include/flang/Semantics/tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ bool IsDeviceAllocatable(const Symbol &symbol);

inline bool IsCUDADeviceContext(const Scope *scope) {
if (scope) {
if (const Symbol * symbol{scope->symbol()}) {
if (const Symbol *symbol{scope->symbol()}) {
if (const auto *subp{symbol->detailsIf<SubprogramDetails>()}) {
if (auto attrs{subp->cudaSubprogramAttrs()}) {
return *attrs != common::CUDASubprogramAttrs::Host;
Expand Down Expand Up @@ -305,7 +305,7 @@ const Symbol *FindExternallyVisibleObject(const A &, const Scope &) {
template <typename T>
const Symbol *FindExternallyVisibleObject(
const evaluate::Designator<T> &designator, const Scope &scope) {
if (const Symbol * symbol{designator.GetBaseObject().symbol()}) {
if (const Symbol *symbol{designator.GetBaseObject().symbol()}) {
return FindExternallyVisibleObject(*symbol, scope, false);
} else if (std::holds_alternative<evaluate::CoarrayRef>(designator.u)) {
// Coindexed values are visible even if their image-local objects are not.
Expand Down Expand Up @@ -670,8 +670,8 @@ class LabelEnforce {
LabelEnforce(SemanticsContext &context, std::set<parser::Label> &&labels,
parser::CharBlock constructSourcePosition, const char *construct)
: context_{context}, labels_{labels},
constructSourcePosition_{constructSourcePosition}, construct_{
construct} {}
constructSourcePosition_{constructSourcePosition},
construct_{construct} {}
template <typename T> bool Pre(const T &) { return true; }
template <typename T> bool Pre(const parser::Statement<T> &statement) {
currentStatementSourcePosition_ = statement.source;
Expand Down
2 changes: 1 addition & 1 deletion flang/include/flang/Semantics/unparse-with-symbols.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ void UnparseWithSymbols(llvm::raw_ostream &, const parser::Program &,
void UnparseWithModules(llvm::raw_ostream &, SemanticsContext &,
const parser::Program &,
parser::Encoding encoding = parser::Encoding::UTF_8);
}
} // namespace Fortran::semantics

#endif // FORTRAN_SEMANTICS_UNPARSE_WITH_SYMBOLS_H_
10 changes: 5 additions & 5 deletions flang/lib/Semantics/assignment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class AssignmentContext {
};

void AssignmentContext::Analyze(const parser::AssignmentStmt &stmt) {
if (const evaluate::Assignment * assignment{GetAssignment(stmt)}) {
if (const evaluate::Assignment *assignment{GetAssignment(stmt)}) {
const SomeExpr &lhs{assignment->lhs};
const SomeExpr &rhs{assignment->rhs};
auto lhsLoc{std::get<parser::Variable>(stmt.t).GetSource()};
Expand All @@ -72,8 +72,8 @@ void AssignmentContext::Analyze(const parser::AssignmentStmt &stmt) {
std::holds_alternative<evaluate::ProcedureRef>(assignment->u)};
if (isDefinedAssignment) {
flags.set(DefinabilityFlag::AllowEventLockOrNotifyType);
} else if (const Symbol *
whole{evaluate::UnwrapWholeSymbolOrComponentDataRef(lhs)}) {
} else if (const Symbol *whole{
evaluate::UnwrapWholeSymbolOrComponentDataRef(lhs)}) {
if (IsAllocatable(whole->GetUltimate())) {
flags.set(DefinabilityFlag::PotentialDeallocation);
}
Expand Down Expand Up @@ -101,7 +101,7 @@ void AssignmentContext::Analyze(const parser::AssignmentStmt &stmt) {

void AssignmentContext::Analyze(const parser::PointerAssignmentStmt &stmt) {
CHECK(whereDepth_ == 0);
if (const evaluate::Assignment * assignment{GetAssignment(stmt)}) {
if (const evaluate::Assignment *assignment{GetAssignment(stmt)}) {
parser::CharBlock at{context_.location().value()};
auto restorer{foldingContext().messages().SetLocation(at)};
CheckPointerAssignment(context_, *assignment, context_.FindScope(at));
Expand All @@ -125,7 +125,7 @@ static std::optional<std::string> GetPointerComponentDesignatorName(
bool CheckCopyabilityInPureScope(parser::ContextualMessages &messages,
const SomeExpr &expr, const Scope &scope) {
if (auto pointer{GetPointerComponentDesignatorName(expr)}) {
if (const Symbol * base{GetFirstSymbol(expr)}) {
if (const Symbol *base{GetFirstSymbol(expr)}) {
const char *why{WhyBaseObjectIsSuspicious(base->GetUltimate(), scope)};
if (!why) {
if (auto coarray{evaluate::ExtractCoarrayRef(expr)}) {
Expand Down
2 changes: 1 addition & 1 deletion flang/lib/Semantics/canonicalize-acc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class CanonicalizationOfAcc {
return; // Tile is not allowed on DO CONCURRENT
}
for (const parser::DoConstruct *loop{&outer}; loop && tileArgNb > 0;
--tileArgNb) {
--tileArgNb) {
const auto &block{std::get<parser::Block>(loop->t)};
const auto it{block.begin()};
loop = it != block.end() ? parser::Unwrap<parser::DoConstruct>(*it)
Expand Down
4 changes: 2 additions & 2 deletions flang/lib/Semantics/check-acc-structure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -667,8 +667,8 @@ void AccStructureChecker::Enter(const parser::OpenACCCacheConstruct &x) {
PushContextAndClauseSets(verbatim.source, llvm::acc::Directive::ACCD_cache);
SetContextDirectiveSource(verbatim.source);
if (loopNestLevel == 0) {
context_.Say(verbatim.source,
"The CACHE directive must be inside a loop"_err_en_US);
context_.Say(
verbatim.source, "The CACHE directive must be inside a loop"_err_en_US);
}
}
void AccStructureChecker::Leave(const parser::OpenACCCacheConstruct &x) {
Expand Down
45 changes: 22 additions & 23 deletions flang/lib/Semantics/check-allocate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class AllocationCheckerHelper {
if (type_->category() == DeclTypeSpec::Category::Character) {
hasDeferredTypeParameter_ =
type_->characterTypeSpec().length().isDeferred();
} else if (const DerivedTypeSpec * derivedTypeSpec{type_->AsDerived()}) {
} else if (const DerivedTypeSpec *derivedTypeSpec{type_->AsDerived()}) {
for (const auto &pair : derivedTypeSpec->parameters()) {
hasDeferredTypeParameter_ |= pair.second.isDeferred();
}
Expand Down Expand Up @@ -114,7 +114,7 @@ static std::optional<AllocateCheckerInfo> CheckAllocateOptions(
}
info.gotTypeSpec = true;
info.typeSpecLoc = parser::FindSourceLocation(*typeSpec);
if (const DerivedTypeSpec * derived{info.typeSpec->AsDerived()}) {
if (const DerivedTypeSpec *derived{info.typeSpec->AsDerived()}) {
// C937
if (auto it{FindCoarrayUltimateComponent(*derived)}) {
context
Expand Down Expand Up @@ -224,8 +224,8 @@ static std::optional<AllocateCheckerInfo> CheckAllocateOptions(
}
info.sourceExprRank = expr->Rank();
info.sourceExprLoc = parserSourceExpr->source;
if (const DerivedTypeSpec *
derived{evaluate::GetDerivedTypeSpec(info.sourceExprType)}) {
if (const DerivedTypeSpec *derived{
evaluate::GetDerivedTypeSpec(info.sourceExprType)}) {
// C949
if (auto it{FindCoarrayUltimateComponent(*derived)}) {
context
Expand Down Expand Up @@ -279,13 +279,13 @@ static std::optional<AllocateCheckerInfo> CheckAllocateOptions(
// in this test.
static bool IsTypeCompatible(
const DeclTypeSpec &type1, const DerivedTypeSpec &derivedType2) {
if (const DerivedTypeSpec * derivedType1{type1.AsDerived()}) {
if (const DerivedTypeSpec *derivedType1{type1.AsDerived()}) {
if (type1.category() == DeclTypeSpec::Category::TypeDerived) {
return evaluate::AreSameDerivedTypeIgnoringTypeParameters(
*derivedType1, derivedType2);
} else if (type1.category() == DeclTypeSpec::Category::ClassDerived) {
for (const DerivedTypeSpec *parent{&derivedType2}; parent;
parent = parent->typeSymbol().GetParentTypeSpec()) {
parent = parent->typeSymbol().GetParentTypeSpec()) {
if (evaluate::AreSameDerivedTypeIgnoringTypeParameters(
*derivedType1, *parent)) {
return true;
Expand All @@ -303,13 +303,13 @@ static bool IsTypeCompatible(
// cannot be allocatable (C709)
return true;
}
if (const IntrinsicTypeSpec * intrinsicType2{type2.AsIntrinsic()}) {
if (const IntrinsicTypeSpec * intrinsicType1{type1.AsIntrinsic()}) {
if (const IntrinsicTypeSpec *intrinsicType2{type2.AsIntrinsic()}) {
if (const IntrinsicTypeSpec *intrinsicType1{type1.AsIntrinsic()}) {
return intrinsicType1->category() == intrinsicType2->category();
} else {
return false;
}
} else if (const DerivedTypeSpec * derivedType2{type2.AsDerived()}) {
} else if (const DerivedTypeSpec *derivedType2{type2.AsDerived()}) {
return IsTypeCompatible(type1, *derivedType2);
}
return false;
Expand All @@ -323,7 +323,7 @@ static bool IsTypeCompatible(
return true;
}
if (type2.category() != evaluate::TypeCategory::Derived) {
if (const IntrinsicTypeSpec * intrinsicType1{type1.AsIntrinsic()}) {
if (const IntrinsicTypeSpec *intrinsicType1{type1.AsIntrinsic()}) {
return intrinsicType1->category() == type2.category();
} else {
return false;
Expand All @@ -348,16 +348,16 @@ static bool HaveSameAssumedTypeParameters(
}
// It is possible to reach this if type1 is unlimited polymorphic
return !type2LengthIsAssumed;
} else if (const DerivedTypeSpec * derivedType2{type2.AsDerived()}) {
} else if (const DerivedTypeSpec *derivedType2{type2.AsDerived()}) {
int type2AssumedParametersCount{0};
int type1AssumedParametersCount{0};
for (const auto &pair : derivedType2->parameters()) {
type2AssumedParametersCount += pair.second.isAssumed();
}
// type1 may be unlimited polymorphic
if (const DerivedTypeSpec * derivedType1{type1.AsDerived()}) {
if (const DerivedTypeSpec *derivedType1{type1.AsDerived()}) {
for (auto it{derivedType1->parameters().begin()};
it != derivedType1->parameters().end(); ++it) {
it != derivedType1->parameters().end(); ++it) {
if (it->second.isAssumed()) {
++type1AssumedParametersCount;
const ParamValue *param{derivedType2->FindParameter(it->first)};
Expand All @@ -378,8 +378,8 @@ static bool HaveSameAssumedTypeParameters(

static std::optional<std::int64_t> GetTypeParameterInt64Value(
const Symbol &parameterSymbol, const DerivedTypeSpec &derivedType) {
if (const ParamValue *
paramValue{derivedType.FindParameter(parameterSymbol.name())}) {
if (const ParamValue *paramValue{
derivedType.FindParameter(parameterSymbol.name())}) {
return evaluate::ToInt64(paramValue->GetExplicit());
}
return std::nullopt;
Expand All @@ -403,11 +403,11 @@ static bool HaveCompatibleTypeParameters(
if (type1.category() == DeclTypeSpec::Category::ClassStar) {
return true;
}
if (const IntrinsicTypeSpec * intrinsicType1{type1.AsIntrinsic()}) {
if (const IntrinsicTypeSpec *intrinsicType1{type1.AsIntrinsic()}) {
return evaluate::ToInt64(intrinsicType1->kind()).value() == type2.kind();
} else if (type2.IsUnlimitedPolymorphic()) {
return false;
} else if (const DerivedTypeSpec * derivedType1{type1.AsDerived()}) {
} else if (const DerivedTypeSpec *derivedType1{type1.AsDerived()}) {
return HaveCompatibleTypeParameters(
*derivedType1, type2.GetDerivedTypeSpec());
} else {
Expand All @@ -419,10 +419,10 @@ static bool HaveCompatibleTypeParameters(
const DeclTypeSpec &type1, const DeclTypeSpec &type2) {
if (type1.category() == DeclTypeSpec::Category::ClassStar) {
return true;
} else if (const IntrinsicTypeSpec * intrinsicType1{type1.AsIntrinsic()}) {
} else if (const IntrinsicTypeSpec *intrinsicType1{type1.AsIntrinsic()}) {
const IntrinsicTypeSpec *intrinsicType2{type2.AsIntrinsic()};
return !intrinsicType2 || intrinsicType1->kind() == intrinsicType2->kind();
} else if (const DerivedTypeSpec * derivedType1{type1.AsDerived()}) {
} else if (const DerivedTypeSpec *derivedType1{type1.AsDerived()}) {
const DerivedTypeSpec *derivedType2{type2.AsDerived()};
return !derivedType2 ||
HaveCompatibleTypeParameters(*derivedType1, *derivedType2);
Expand Down Expand Up @@ -699,8 +699,7 @@ bool AllocationCheckerHelper::RunCoarrayRelatedChecks(
if (evaluate::IsCoarray(*ultimate_)) {
if (allocateInfo_.gotTypeSpec) {
// C938
if (const DerivedTypeSpec *
derived{allocateInfo_.typeSpec->AsDerived()}) {
if (const DerivedTypeSpec *derived{allocateInfo_.typeSpec->AsDerived()}) {
if (IsTeamType(derived)) {
context
.Say(allocateInfo_.typeSpecLoc.value(),
Expand Down Expand Up @@ -784,8 +783,8 @@ bool AllocationCheckerHelper::RunCoarrayRelatedChecks(
return false;
}
}
if (const parser::CoindexedNamedObject *
coindexedObject{parser::GetCoindexedNamedObject(allocateObject_)}) {
if (const parser::CoindexedNamedObject *coindexedObject{
parser::GetCoindexedNamedObject(allocateObject_)}) {
// C950
context.Say(parser::FindSourceLocation(*coindexedObject),
"Allocatable object must not be coindexed in ALLOCATE"_err_en_US);
Expand Down
2 changes: 1 addition & 1 deletion flang/lib/Semantics/check-arithmeticif.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ struct ArithmeticIfStmt;
namespace Fortran::semantics {
class ArithmeticIfStmtChecker : public virtual BaseChecker {
public:
ArithmeticIfStmtChecker(SemanticsContext &context) : context_(context){};
ArithmeticIfStmtChecker(SemanticsContext &context) : context_(context) {}
void Leave(const parser::ArithmeticIfStmt &);

private:
Expand Down
Loading