On Thu, Feb 22, 2024 at 05:49:12PM +0000, Joseph Myers wrote: > This patch (the one using COLON_SCOPE, *not* the one using PREV_WHITE) is > OK. > > PREV_WHITE is about whether there is whitespace between the tokens in the > macro expansion, for the purposes of stringization - I don't think it's > appropriate to use here. For example, given > > #define COLON() : > > then > > [[gnu COLON()COLON() unused]] int x; > > should preferably not be valid; stringizing the results of expanding > COLON()COLON() will produce "::" (PREV_WHITE not set), but that wouldn't > be a valid attribute in C23 and I don't think anyone could reasonably > expect it to be valid with previous standard versions.
It is not valid in either version of the patch, with any of -std=c11, -std=gnu11 or -std=c23 with both compilers I get the same /tmp/test.c:2:1: warning: ‘gnu’ attribute ignored [-Wattributes] 2 | [[gnu COLON()COLON() unused]] int x; | ^ /tmp/test.c:2:6: error: expected ‘]’ before ‘:’ token 2 | [[gnu COLON()COLON() unused]] int x; | ^ | ] message all the time. But sure, if you prefer the COLON_SCOPE version of the patch, I can commit that. There is no PREV_WHITE in the preprocessor, there is CPP_PADDING token in between the CPP_COLONs though and that translates into PREV_WHITE on the second CPP_COLON in the FE token. When trying to verify it, I've noticed one typo in the PREV_WHITE patch: @@ -73,7 +73,7 @@ gcc/testsuite/ switch (type) { case CPP_PADDING: -+ add_flags |= CPP_PADDING; ++ add_flags |= PREV_WHITE; goto retry; case CPP_NAME: but it doesn't change anything on the outcome of those tests nor your testcase above nor the C++ -std=c++98 -fpermissive test. CPP_PADDING is 85 and PREV_WHITE 1, so it was setting PREV_WHITE too (just 3 other flags too). Jakub