}
}
} else if (dirName == "ifdef" || dirName == "ifndef") {
+ bool doThen{false};
if (nameToken.empty()) {
+ // Warning, not error, in PGI.
+ // This misusage appears in WRF & other SPEC codes (might be a local mod).
prescanner->Say(
dir.GetIntervalProvenanceRange(dirOffset, tokens - dirOffset),
- "#%s: missing name"_err_en_US, dirName.data());
- return;
+ "#%s: missing name"_en_US, dirName.data());
+ } else {
+ j = dir.SkipBlanks(j + 1);
+ if (j != tokens) {
+ prescanner->Say(dir.GetIntervalProvenanceRange(j, tokens - j),
+ "#%s: excess tokens at end of directive"_en_US, dirName.data());
+ }
+ doThen = IsNameDefined(nameToken) == (dirName == "ifdef");
}
- j = dir.SkipBlanks(j + 1);
- if (j != tokens) {
- prescanner->Say(dir.GetIntervalProvenanceRange(j, tokens - j),
- "#%s: excess tokens at end of directive"_err_en_US, dirName.data());
- } else if (IsNameDefined(nameToken) == (dirName == "ifdef")) {
+ if (doThen) {
ifStack_.push(CanDeadElseAppear::Yes);
} else {
SkipDisabledConditionalCode(dirName, IsElseActive::Yes, prescanner,
add_executable(f18-parse-demo
f18-parse-demo.cc
+ stub-evaluate.cc
)
target_link_libraries(f18-parse-demo
FortranParser
- FortranEvaluate
)
}
}
+#if _POSIX_C_SOURCE >= 199309L && defined CLOCK_PROCESS_CPUTIME_ID
+static constexpr bool canTime{true};
double CPUseconds() {
struct timespec tspec;
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &tspec);
return tspec.tv_nsec * 1.0e-9 + tspec.tv_sec;
}
+#else
+static constexpr bool canTime{false};
+double CPUseconds() { return 0; }
+#endif
struct DriverOptions {
DriverOptions() {}
parsing.Parse(&std::cout);
auto stop{CPUseconds()};
if (driver.timeParse) {
- std::cout << "parse time for " << path << ": " << (stop - start)
- << " CPU seconds\n";
+ if (canTime) {
+ std::cout << "parse time for " << path << ": " << (stop - start)
+ << " CPU seconds\n";
+ } else {
+ std::cout << "no timing information due to lack of clock_gettime()\n";
+ }
}
parsing.ClearLog();
--- /dev/null
+// 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.
+// 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.
+
+// The parse tree has slots in which pointers to typed expressions may be
+// placed. When using the parser without the expression library, as here,
+// we need to stub out the dependence.
+
+#include "../../lib/common/indirection.h"
+
+namespace Fortran::evaluate {
+struct GenericExprWrapper {
+ bool operator==(const GenericExprWrapper &) const { return false; }
+};
+}
+
+DEFINE_OWNING_DESTRUCTOR(OwningPointer, evaluate::GenericExprWrapper)