[flang] Fix bug flang-compiler/f18#437, func-like macro call with no arguments

Original-commit: flang-compiler/f18@d106290f19
Reviewed-on: https://github.com/flang-compiler/f18/pull/438
Tree-same-pre-rewrite: false
This commit is contained in:
peter klausler 2019-05-02 14:29:52 -07:00
parent 4245cae846
commit b3682933f3
1 changed files with 6 additions and 2 deletions

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.
@ -319,6 +319,10 @@ std::optional<TokenSequence> Preprocessor::MacroReplacement(
}
}
}
if (argStart.size() == 1 && argStart[0] == k) {
// empty parentheses, no arguments
argStart.clear();
}
if (k >= tokens || argStart.size() < def.argumentCount() ||
(argStart.size() > def.argumentCount() && !def.isVariadic())) {
result.Put(input, j);
@ -344,7 +348,7 @@ std::optional<TokenSequence> Preprocessor::MacroReplacement(
}
j = k; // advance to the terminal ')'
}
return {result};
return result;
}
TokenSequence Preprocessor::ReplaceMacros(