[flang] Strip whitespace from parse tree source locations
Parse tree nodes have `source` fields that map the node back to a range in the cooked input stream. These are used for names and to locate error messages. This change strips spaces from the beginning and end of those source ranges before they are saved. This fixes two problems: 1. For a statement like this: `generic :: operator(+) => ...`, the name of the symbol we want to create is "operator(+)" but the parser was including the following space in the CharBlock it captured. 2. Error messages referring to parts of expressions sometimes included extra spaces in the source locations. For example: ``` t.f90:9:29: error: subscripts may be applied only to an object or component integer, parameter :: b = a(1) + 1 ^^^^^ t.f90:4:8: error: operands to LOGICAL operation must be LOGICAL i = j .or. k ^^^^^^^ ``` Original-commit: flang-compiler/f18@fa14297967b7852fd130790eca4186f259f0a1f2 Reviewed-on: https://github.com/flang-compiler/f18/pull/343 Tree-same-pre-rewrite: false
Loading
Please sign in to comment