Hi ! While porting a GCC 4.9 private port to GCC 7, I've encountered an issue with named address space support.
I have defined the following target macros: #define K1_ADDR_SPACE_UNCACHED 1 #define K1_ADDR_SPACE_CONVERT 2 TARGET_ADDR_SPACE_LEGITIMATE_ADDRESS_P (returns false for CONVERT, regular legitimate hook for other as) TARGET_ADDR_SPACE_LEGITIMIZE_ADDRESS (raises an error if using CONVERT as or calls regular legitimize_address hook) TARGET_ADDR_SPACE_SUBSET_P (always true) TARGET_ADDR_SPACE_CONVERT (emits a warning if not to/from CONVERT as and always returns first operand) #define REGISTER_TARGET_PRAGMAS() do { \ c_register_addr_space ("__uncached", K1_ADDR_SPACE_UNCACHED); \ c_register_addr_space ("__convert", K1_ADDR_SPACE_CONVERT); \ } while (0) The usage is very basic and is used to drive the insn selection to use cached/uncached variants for load/store. Pointers are declared with `__uncached` to use uncached variants and `__convert` is used when converting pointers to/from this uncached space. It works as expected on GCC 4.9. On our current port on GCC 7 (using latest gcc-7-branch branch), we have an issue with simple code: ``` typedef struct { unsigned long count; } foo_t; unsigned long foobar(foo_t *cond, int bar) { if (bar == 1 ) { } __uncached foo_t *ucond = cond; return ucond->count; } ``` Raises the following error: ``` <source>: In function 'foobar': <source>:9:3: error: unknown type name '__uncached' __uncached foo_t *ucond = cond; ^~~~~~~~~~ <source>:9:20: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token __uncached foo_t *ucond = cond; ^ <source>:10:10: error: 'ucond' undeclared (first use in this function); did you mean 'cond'? return ucond->count; ^~~~~ cond <source>:10:10: note: each undeclared identifier is reported only once for each function it appears in Compiler returned: 1 ``` The following changes make the code compile as expected: - moving the variable declaration at the beginning of the block - opening a block before the declaration and closing it after the return stmt. I could not find a matching PR in bugzilla. Do you know of any issue with this ? Maybe this has been fixed in later versions. Thanks, Marc