forked from OSchip/llvm-project
[flang] Final tweaks, can now parse all SPEC CPUv6
Original-commit: flang-compiler/f18@015152f1ba Reviewed-on: https://github.com/flang-compiler/f18/pull/335 Tree-same-pre-rewrite: false
This commit is contained in:
parent
827407a86a
commit
713cd91a34
|
@ -366,6 +366,9 @@ void Preprocessor::Directive(const TokenSequence &dir, Prescanner *prescanner) {
|
|||
return;
|
||||
}
|
||||
j = dir.SkipBlanks(j + 1);
|
||||
while (tokens > 0 && dir.TokenAt(tokens - 1).IsBlank()) {
|
||||
--tokens;
|
||||
}
|
||||
if (j == tokens) {
|
||||
return;
|
||||
}
|
||||
|
@ -525,11 +528,12 @@ void Preprocessor::Directive(const TokenSequence &dir, Prescanner *prescanner) {
|
|||
} else if (dirName == "error") {
|
||||
prescanner->Say(
|
||||
dir.GetIntervalProvenanceRange(dirOffset, tokens - dirOffset),
|
||||
"#error: %s"_err_en_US, dir.ToString().data());
|
||||
} else if (dirName == "warning") {
|
||||
"%s"_err_en_US, dir.ToString().data());
|
||||
} else if (dirName == "warning" || dirName == "comment" ||
|
||||
dirName == "note") {
|
||||
prescanner->Say(
|
||||
dir.GetIntervalProvenanceRange(dirOffset, tokens - dirOffset),
|
||||
"#warning: %s"_en_US, dir.ToString().data());
|
||||
"%s"_en_US, dir.ToString().data());
|
||||
} else if (dirName == "include") {
|
||||
if (j == tokens) {
|
||||
prescanner->Say(
|
||||
|
@ -539,12 +543,23 @@ void Preprocessor::Directive(const TokenSequence &dir, Prescanner *prescanner) {
|
|||
}
|
||||
std::string include;
|
||||
if (dir.TokenAt(j).ToString() == "<") {
|
||||
if (dir.TokenAt(tokens - 1).ToString() != ">") {
|
||||
std::size_t k{j + 1};
|
||||
if (k >= tokens) {
|
||||
prescanner->Say(dir.GetIntervalProvenanceRange(j, tokens - j),
|
||||
"#include: expected '>' at end of directive"_err_en_US);
|
||||
"#include: file name missing"_err_en_US);
|
||||
return;
|
||||
}
|
||||
TokenSequence braced{dir, j + 1, tokens - j - 2};
|
||||
while (k < tokens && dir.TokenAt(k) != ">") {
|
||||
++k;
|
||||
}
|
||||
if (k >= tokens) {
|
||||
prescanner->Say(dir.GetIntervalProvenanceRange(j, tokens - j),
|
||||
"#include: expected '>' at end of included file"_en_US);
|
||||
} else if (k + 1 < tokens) {
|
||||
prescanner->Say(dir.GetIntervalProvenanceRange(k + 1, tokens - k - 1),
|
||||
"#include: extra stuff ignored after '>'"_en_US);
|
||||
}
|
||||
TokenSequence braced{dir, j + 1, k - j - 1};
|
||||
include = ReplaceMacros(braced, *prescanner).ToString();
|
||||
} else if (j + 1 == tokens &&
|
||||
(include = dir.TokenAt(j).ToString()).substr(0, 1) == "\"" &&
|
||||
|
|
Loading…
Reference in New Issue