Jason Merrill <[email protected]> writes: > But we don't do that for const. In C++ the quals apply to the element type > rather than the array type; see build_cplus_array_type and cp_type_quals for > places that deal with that. Places that call > > cp_apply_type_quals_to_decl (cp_type_quals (type), decl); > > handle setting TREE_READONLY and such on the decl; is there a parallel for > address space?
AFAICT no, I see nothing similar to DECL_READONLY etc but for address spaces on decls. On top of that, anything that wants to know the address space of whatever it may be checks the type of the decl/operand/... for it directly (and, manually each time, so there's not even a EXPR_OR_DECL_ADDR_SPACE or such :S), at a glance with grep[1]. The narrow issue Johann originally reported can be fixed by teaching varasm to strip arrays before concluding what address space some variable is. But the rest of the compiler would probably need similar changes, as, AFAICT, it all assumes that TREE_ADDR_SPACE (array) is set to TREE_ADDR_SPACE (TREE_TYPE (array)) prior to using it. Alternatively, of course, we could make such a EXPR_OR_DECL_ADDR_SPACE and replace all (applicable) usages of TYPE_ADDR_SPACE with it. I think it'd be semantically sound to make GENERIC semantics match C++ when dealing with address spaces on array types (i.e. define that the the address space of an array type is the address space of the element type; nothing else really makes sense after all), so it may be best to make TYPE_ADDR_SPACE strip arrays. This would probably make it not an lvalue, but only a handful of places use TYPE_ADDR_SPACE as an lvalue anyway, so that's not a big burden. Though, that may be a bit awkward in relation to TYPE_QUALS, as, suddenly, one of the qualifiers it reads is not necessarily applicable on the type given to it. What do you think is best? I'm thinking that the latter gets rid of the whole ambiguity, and so, may be the best solution overall. [1] rg -NI -o -g '*.cc' -g '!cp' -g '!c-family' -g '!c' '[A-Za-z0-9_]*_ADDR_SPACE(_[A-Za-z0-9_]*)?' | sort -u -- Arsen Arsenović
signature.asc
Description: PGP signature
