Index: flang/lib/Parser/preprocessor.cpp =================================================================== --- flang/lib/Parser/preprocessor.cpp +++ flang/lib/Parser/preprocessor.cpp @@ -169,8 +169,9 @@ replacement_.TokenAt(prev - 1)[0] == '#') { // stringify argument without macro replacement std::size_t resultSize{result.SizeInTokens()}; - while (resultSize > 0 && result.TokenAt(resultSize - 1).empty()) { + while (resultSize > 0 && result.TokenAt(resultSize - 1).IsBlank()) { result.pop_back(); + --resultSize; } CHECK(resultSize > 0 && result.TokenAt(resultSize - 1) == replacement_.TokenAt(prev - 1)); Index: flang/test/Preprocessing/pp045.F =================================================================== --- /dev/null +++ flang/test/Preprocessing/pp045.F @@ -0,0 +1,9 @@ +! RUN: %flang -E %s 2>&1 | FileCheck %s +! CHECK: n = "foobar" // "baz" +* # stringizing works in FLM +#define STR(x) # x +#define MAC(a,b) STR(a ## b) + program main + character(6) n + n = MAC(foo, bar) // STR( baz ) + end Index: flang/test/Preprocessing/pp131.F90 =================================================================== --- /dev/null +++ flang/test/Preprocessing/pp131.F90 @@ -0,0 +1,9 @@ +! RUN: %flang -E %s 2>&1 | FileCheck %s +! CHECK: n = "foobar" // "baz" +! # stringizing works in FLM +#define STR(x) # x +#define MAC(a,b) STR(a ## b) +program main + character(6) n + n = MAC(foo, bar) // STR( baz ) +end