https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119438

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This should not be too hard to add, current code does:
```
      /* Check the stringifying # constraint 6.10.3.2.1 of
         function-like macros when lexing the subsequent token.  */
      if (macro->count > 1 && token[-1].type == CPP_HASH && macro->fun_like)
        {
          if (token->type == CPP_MACRO_ARG
              || (macro->variadic
                  && token->type == CPP_NAME
                  && token->val.node.node == pfile->spec_nodes.n__VA_OPT__))
            {
              if (token->flags & PREV_WHITE)
                token->flags |= SP_PREV_WHITE;
              if (token[-1].flags & DIGRAPH)
                token->flags |= SP_DIGRAPH;
              token->flags &= ~PREV_WHITE;
              token->flags |= STRINGIFY_ARG;
              token->flags |= token[-1].flags & PREV_WHITE;
              token[-1] = token[0];
              macro->count--;
            }
          /* Let assembler get away with murder.  */
          else if (CPP_OPTION (pfile, lang) != CLK_ASM)
            {
              cpp_error (pfile, CPP_DL_ERROR,
                         "%<#%> is not followed by a macro parameter");
              goto out;
            }
        }

```

Basically we need to give out a better error message here.

As far as the location, token[-1].src_loc contains the location of the #.

So `s/cpp_error (pfile, CPP_DL_ERROR,/cpp_error_at (pfile, CPP_DL_ERROR,
token[-1].src_loc,/` should work better. Maybe even just `0` instead of `-1` to
point to the token following `#`.

This whole function (create_iso_definition) needs the cpp_error_at treatment I
think too.

Reply via email to