aboutsummaryrefslogtreecommitdiff
path: root/flang/lib/Parser/preprocessor.cpp
diff options
context:
space:
mode:
authorPeter Klausler <pklausler@nvidia.com>2025-08-29 11:57:59 -0700
committerGitHub <noreply@github.com>2025-08-29 11:57:59 -0700
commit943c7042c622c331784f7eadc35e732ae62aef52 (patch)
tree8abdf8d2e307edc39b5667a2c2766cd50c22f1f3 /flang/lib/Parser/preprocessor.cpp
parent3f6768c0d1c743574acab43c54029f6c142909c6 (diff)
downloadllvm-943c7042c622c331784f7eadc35e732ae62aef52.zip
llvm-943c7042c622c331784f7eadc35e732ae62aef52.tar.gz
llvm-943c7042c622c331784f7eadc35e732ae62aef52.tar.bz2
[flang] Support #if defined when no definitions (#156080)
The "defined" operator isn't working in #if/#elif expressions when there are no defined macros. Fix.
Diffstat (limited to 'flang/lib/Parser/preprocessor.cpp')
-rw-r--r--flang/lib/Parser/preprocessor.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/flang/lib/Parser/preprocessor.cpp b/flang/lib/Parser/preprocessor.cpp
index ae14e2d..9176b4d 100644
--- a/flang/lib/Parser/preprocessor.cpp
+++ b/flang/lib/Parser/preprocessor.cpp
@@ -414,7 +414,7 @@ std::optional<TokenSequence> Preprocessor::MacroReplacement(
const TokenSequence &input, Prescanner &prescanner,
std::optional<std::size_t> *partialFunctionLikeMacro, bool inIfExpression) {
// Do quick scan for any use of a defined name.
- if (definitions_.empty()) {
+ if (!inIfExpression && definitions_.empty()) {
return std::nullopt;
}
std::size_t tokens{input.SizeInTokens()};