[flang] Remove macro replacement in angular bracket includes
authorEthan Luis McDonough <ethanluismcdonough@gmail.com>
Sat, 18 Feb 2023 07:56:15 +0000 (01:56 -0600)
committerEthan Luis McDonough <ethanluismcdonough@gmail.com>
Sat, 18 Feb 2023 07:59:32 +0000 (01:59 -0600)
Addresses Github issue [[ https://github.com/llvm/llvm-project/issues/60317 | #60317 ]].

Reviewed By: klausler

Differential Revision: https://reviews.llvm.org/D143469

flang/lib/Parser/preprocessor.cpp
flang/test/Preprocessing/preserve-brace-include.F90 [new file with mode: 0644]

index c8f944e..58b54f4 100644 (file)
@@ -599,7 +599,7 @@ void Preprocessor::Directive(const TokenSequence &dir, Prescanner &prescanner) {
             "#include: expected '>' at end of included file"_port_en_US);
       }
       TokenSequence braced{dir, j + 1, k - j - 1};
-      include = ReplaceMacros(braced, prescanner).ToString();
+      include = braced.ToString();
       j = k;
     } else if ((include = dir.TokenAt(j).ToString()).substr(0, 1) == "\"" &&
         include.substr(include.size() - 1, 1) == "\"") { // #include "foo"
diff --git a/flang/test/Preprocessing/preserve-brace-include.F90 b/flang/test/Preprocessing/preserve-brace-include.F90
new file mode 100644 (file)
index 0000000..22df354
--- /dev/null
@@ -0,0 +1,5 @@
+! RUN: %flang -E -I%S %s | FileCheck %s
+
+#define empty ERR_NONEXISTENT
+! CHECK-NOT: :5:
+#include <empty.h>