Martin Koegler wrote:
          tree type = TREE_TYPE (*node);
          tree attr = tree_cons (name, args, TYPE_ATTRIBUTES (type));
          tree newtype = build_type_attribute_variant (type, attr);
          TYPE_MAIN_VARIANT (newtype) = TYPE_MAIN_VARIANT (type);
          TREE_TYPE (*node) = newtype;

You shouldn't be trying to build your own types in a machine dependent attribute handler function. The compiler's type system is determined by front-ends mainly, and some middle-end infrastructure, and isn't your domain to mess with. This stuff is subject to change, at which point your code may break.


The sensible thing here would be to give an error message if an attribute is misused.

There are a number of subtleties in the type system relating to arrays, so it isn't surprising that you are having trouble with them. For instance, you can't apply some kinds of type modifiers to array types, they have to be applied to the array element types instead.

I think the problem with your code is that you are setting TYPE_MAIN_VARIANT to point at the original type. TYPE_MAIN_VARIANT is only supposed to be used in the presence of type qualifiers like const and volatile, to point at the unqualified type. But you have no type qualifiers here, and hence TYPE_MAIN_VARIANT should point at itself.

See the gcc internals docs for TYPE_MAIN_VARIANT which specifically mentions type qualifiers.
--
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com

Reply via email to