On Wed, Nov 29, 2017 at 10:33:04AM +0100, Jakub Jelinek wrote:
> > -  /* We need to create a name, since complex is a fundamental type.  */
> > -  if (!TYPE_NAME (t) && named)
> > +      /* We need to create a name, since complex is a fundamental type.  */
> > +      if (named)
> > +   {
> > +     const char *name = NULL;
> > +
> > +     if (TREE_TYPE (t) == char_type_node)
> > +       name = "complex char";
> > +     else if (TREE_TYPE (t) == signed_char_type_node)
> > +       name = "complex signed char";
> > +     else if (TREE_TYPE (t) == unsigned_char_type_node)
> > +       name = "complex unsigned char";
> > +     else if (TREE_TYPE (t) == short_integer_type_node)
> > +       name = "complex short int";
> > +     else if (TREE_TYPE (t) == short_unsigned_type_node)
> > +       name = "complex short unsigned int";
> > +     else if (TREE_TYPE (t) == integer_type_node)
> > +       name = "complex int";
> > +     else if (TREE_TYPE (t) == unsigned_type_node)
> > +       name = "complex unsigned int";
> > +     else if (TREE_TYPE (t) == long_integer_type_node)
> > +       name = "complex long int";
> > +     else if (TREE_TYPE (t) == long_unsigned_type_node)
> > +       name = "complex long unsigned int";
> > +     else if (TREE_TYPE (t) == long_long_integer_type_node)
> > +       name = "complex long long int";
> > +     else if (TREE_TYPE (t) == long_long_unsigned_type_node)
> > +       name = "complex long long unsigned int";
> > +
> > +     if (name != NULL)
> > +       TYPE_NAME (t) = build_decl (UNKNOWN_LOCATION, TYPE_DECL,
> > +                                   get_identifier (name), t);
> > +   }
> 
> Are you sure nothing can build_complex_type before build_common_tree_nodes
> is called and builds those?  If that would happen, we'd fail to add names
> with your patch, while we'd add them before.  The addition of TYPE_NAME
> looks orthogonal to the TYPE_CANONICAL handling and type hashing.
> I must also say I'm surprised that the recursive build_complex_type
> call passes in named too, but as it does type comparison by pointers,
> perhaps that's ok.

On the other side, the types that are == compared to are also (newly!, not
by reusing existing types) created in build_common_tree_nodes, so I think
your patch is ok as is.

        Jakub

Reply via email to