[all-commits] [llvm/llvm-project] 6fac3f: [flang] Stricter "implicit continuation" in prepro...

Peter Klausler via All-commits all-commits at lists.llvm.org
Mon Jul 31 14:23:36 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 6fac3f7b2e9415d181b8d21af57f4e6a312385a5
      https://github.com/llvm/llvm-project/commit/6fac3f7b2e9415d181b8d21af57f4e6a312385a5
  Author: Peter Klausler <pklausler at nvidia.com>
  Date:   2023-07-31 (Mon, 31 Jul 2023)

  Changed paths:
    M flang/docs/Preprocessing.md
    M flang/include/flang/Parser/char-block.h
    M flang/lib/Parser/preprocessor.cpp
    M flang/lib/Parser/preprocessor.h
    M flang/lib/Parser/prescan.cpp
    M flang/lib/Parser/prescan.h
    M flang/lib/Parser/token-sequence.cpp
    M flang/test/Lower/array-elemental-calls-3.f90
    A flang/test/Preprocessing/implicit-contin1.F90
    A flang/test/Preprocessing/implicit-contin2.F90
    A flang/test/Preprocessing/implicit-contin3.F90
    M flang/test/Preprocessing/pp127.F90
    M flang/test/Semantics/array-constr-big.f90

  Log Message:
  -----------
  [flang] Stricter "implicit continuation" in preprocessing

The prescanner performs implicit line continuation when it looks
like the parenthesized arguments of a call to a function-like macro
may span multiple lines.  In an attempt to work more like a
Fortran-oblivious C preprocessor, the prescanner will act as if
the following lines had been continuations so that the function-like
macro could be invoked.

This still seems like a good idea, but a recent bug report on
LLVM's GitHub issue tracker shows one way in which it could trigger
inadvertently and mess up a program.  So this patch makes the
conditions for implicit line continuation much more strict.

First, the leading parenthesis has to have been preceded by an
identifier that's known to be a macro name.  (It doesn't have to
be a function-like macro, since it's possible for a keyword-like
macro to expand to the name of a function-like macro.)  Second,
no macro definition can ever have had unbalanced parentheses in
its replacement text.

Also cleans up some parenthesis recognition code to fix some
issues found in testing, so that a token with leading or trailing
spaces can still be recognized as a parenthesis or comma.

Fixes https://github.com/llvm/llvm-project/issues/63844.

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




More information about the All-commits mailing list