2019-06-06 22:48:26 +02:00
|
|
|
// Copyright (c) 2018-2019, NVIDIA CORPORATION. All rights reserved.
|
2018-08-09 01:30:58 +02:00
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
#include "common.h"
|
2019-02-01 01:04:17 +01:00
|
|
|
#include "../common/idioms.h"
|
2018-08-09 01:30:58 +02:00
|
|
|
|
|
|
|
using namespace Fortran::parser::literals;
|
|
|
|
|
|
|
|
namespace Fortran::evaluate {
|
|
|
|
|
|
|
|
void RealFlagWarnings(
|
|
|
|
FoldingContext &context, const RealFlags &flags, const char *operation) {
|
|
|
|
if (flags.test(RealFlag::Overflow)) {
|
2019-02-01 01:04:17 +01:00
|
|
|
context.messages().Say("overflow on %s"_en_US, operation);
|
2018-08-09 01:30:58 +02:00
|
|
|
}
|
|
|
|
if (flags.test(RealFlag::DivideByZero)) {
|
2019-02-01 01:04:17 +01:00
|
|
|
context.messages().Say("division by zero on %s"_en_US, operation);
|
2018-08-09 01:30:58 +02:00
|
|
|
}
|
|
|
|
if (flags.test(RealFlag::InvalidArgument)) {
|
2019-02-01 01:04:17 +01:00
|
|
|
context.messages().Say("invalid argument on %s"_en_US, operation);
|
2018-08-09 01:30:58 +02:00
|
|
|
}
|
|
|
|
if (flags.test(RealFlag::Underflow)) {
|
2019-02-01 01:04:17 +01:00
|
|
|
context.messages().Say("underflow on %s"_en_US, operation);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-07 18:57:10 +02:00
|
|
|
ConstantSubscript &FoldingContext::StartImpliedDo(
|
|
|
|
parser::CharBlock name, ConstantSubscript n) {
|
2019-02-01 01:04:17 +01:00
|
|
|
auto pair{impliedDos_.insert(std::make_pair(name, n))};
|
|
|
|
CHECK(pair.second);
|
|
|
|
return pair.first->second;
|
|
|
|
}
|
|
|
|
|
2019-06-07 18:57:10 +02:00
|
|
|
std::optional<ConstantSubscript> FoldingContext::GetImpliedDo(
|
2019-02-01 01:04:17 +01:00
|
|
|
parser::CharBlock name) const {
|
|
|
|
if (auto iter{impliedDos_.find(name)}; iter != impliedDos_.cend()) {
|
|
|
|
return {iter->second};
|
|
|
|
} else {
|
|
|
|
return std::nullopt;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void FoldingContext::EndImpliedDo(parser::CharBlock name) {
|
|
|
|
auto iter{impliedDos_.find(name)};
|
|
|
|
if (iter != impliedDos_.end()) {
|
|
|
|
impliedDos_.erase(iter);
|
2018-08-09 01:30:58 +02:00
|
|
|
}
|
|
|
|
}
|
2018-10-25 14:55:23 +02:00
|
|
|
}
|