Skip to content

Placemarker token at the start of preprocessor expression #949

@Vexu

Description

@Vexu
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
# define FLEXARRAY
#else
# define FLEXARRAY 1
#endif

#if FLEXARRAY+1 > 1
# define SZ_KEYINFO_0   offsetof(KeyInfo,aColl)
#else
# define SZ_KEYINFO_0   sizeof(KeyInfo)
#endif
$ zig build run -- a.c
<scratch space>:0:1: error: invalid token at start of a preprocessor expression

^
1 error generated.

I fixed it by adding a call to removePlacemarkers but I suspect that this also affects pragmas and incudes:

diff --git a/src/aro/Preprocessor.zig b/src/aro/Preprocessor.zig
index 57d7b5fb..85eb8c47 100644
--- a/src/aro/Preprocessor.zig
+++ b/src/aro/Preprocessor.zig
@@ -1139,6 +1139,7 @@ fn expr(pp: *Preprocessor, tokenizer: *Tokenizer) MacroError!bool {
         pp.expansion_source_loc = pp.top_expansion_buf.items[0].loc;
         pp.hideset.clearRetainingCapacity();
         try pp.expandMacroExhaustive(tokenizer, &pp.top_expansion_buf, 0, pp.top_expansion_buf.items.len, false, .expr);
+        removePlacemarkers(gpa, &pp.top_expansion_buf);
     }
     for (pp.top_expansion_buf.items) |tok| {
         if (tok.id == .macro_ws) continue;

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions