[Mesa-dev] [PATCH] glsl: Fixup glcpp tests for redefining a macro with whitespace changes.
Erik Faye-Lund
kusmabite at gmail.com
Tue Jun 17 07:41:21 PDT 2014
On Thu, Jun 12, 2014 at 3:11 AM, Carl Worth <cworth at cworth.org> wrote:
> Previously, the test suite was expecting the compiler to allow a redefintion
> of a macro with whitespace added, but gcc is more strict and allows only for
> changes in the amounts of whitespace, (but insists that whitespace exist or
> not in exactly the same places).
>
> See: https://gcc.gnu.org/onlinedocs/cpp/Undefining-and-Redefining-Macros.html:
>
> These definitions are effectively the same:
>
> #define FOUR (2 + 2)
> #define FOUR (2 + 2)
> #define FOUR (2 /* two */ + 2)
>
> but these are not:
>
> #define FOUR (2 + 2)
> #define FOUR ( 2+2 )
> #define FOUR (2 * 2)
> #define FOUR(score,and,seven,years,ago) (2 + 2)
>
> This change adjusts the existing "redefine-macro-legitimate" test to work with
> the more strict understanding, and adds a new "redefine-whitespace" test to
> verify that changes in the position of whitespace are flagged as errors.
You may want to quote the relevant part from the C++ spec (16.3 Macro
replacement, [cpp.replace]):
Two replacement lists are identical if and only if the preprocessing
tokens in both have the same number, ordering, spelling, and
white-space separation, where all white-space separations are
considered identical.
More information about the mesa-dev
mailing list