From: Anders Björklund Date: Sun, 26 Jun 2016 21:03:59 +0000 (+0200) Subject: Work around preprocessor bugs in gcc version 6 X-Git-Tag: v3.2.6~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a21800173c6d981a3b2d40c57934335a0b08f69f;p=thirdparty%2Fccache.git Work around preprocessor bugs in gcc version 6 Before hashing the output of the preprocessor (gcc -E): - Ignore extra line `# 31 ""` completely. - Replace `# 32 "" 2` with the regular # 1. For some reason this only happens with gcc without macros. Closes #96 --- diff --git a/ccache.c b/ccache.c index b61fac4cb..1197e618e 100644 --- a/ccache.c +++ b/ccache.c @@ -750,6 +750,28 @@ process_preprocessed_file(struct mdfour *hash, const char *path) && (q == data || q[-1] == '\n')) { char *path; + /* Workarounds for preprocessor linemarker bugs in GCC version 6 */ + if (q[2] == '3') { + if (str_startswith(q, "# 31 \"\"\n")) { + /* Bogus extra line with #31, after the regular #1: + Ignore the whole line, and continue parsing */ + while (q < end && *q != '\n') { + q++; + } + p = q; + continue; + } else if (str_startswith(q, "# 32 \"\" 2\n")) { + /* Bogus wrong line with #32, instead of regular #1: + Replace the line number with the usual one */ + hash_buffer(hash, p, q - p); + q += 1; + q[0] = '#'; + q[1] = ' '; + q[2] = '1'; + p = q; + } + } + while (q < end && *q != '"' && *q != '\n') { q++; }