Hi all,
I'm going on brutalizing GIMPLE code to make it more suitable for CIL emition in the CLI be/fe branch and I've stumbled across something which looks really weird. When working with types I always assumed that if 't' is a RECORD_TYPE, UNION_TYPE or QUAL_UNION_TYPE then calling DECL_FIELD_CONTEXT () on its fields yields 't' itself. Chasing a weird bug I had in the test suite I ended up with a case where this wasn't true. This happens in: gcc.c-torture/execute/ieee/fp-cmp-4.c. I've pasted only the relevant code:

int
main()
{
  struct try
  {
    FLOAT x, y;
    unsigned unord : 1;
    unsigned lt : 1;
    unsigned le : 1;
    unsigned gt : 1;
    unsigned ge : 1;
    unsigned lg : 1;
  };

  static struct try const data[] =
  {
    { NAN, NAN, 1, 0, 0, 0, 0, 0 },
    { 0.0, NAN, 1, 0, 0, 0, 0, 0 },
    { NAN, 0.0, 1, 0, 0, 0, 0, 0 },
    { 0.0, 0.0, 0, 0, 1, 0, 1, 0 },
    { 1.0, 2.0, 0, 1, 1, 0, 0, 1 },
    { 2.0, 1.0, 0, 0, 0, 1, 1, 1 },
  };

  const int n = sizeof(data) / sizeof(data[0]);
  int i;

  for (i = 0; i < n; ++i)
    {
      test_isunordered (data[i].x, data[i].y, data[i].unord);
      test_isless (data[i].x, data[i].y, data[i].lt);
      test_islessequal (data[i].x, data[i].y, data[i].le);
      test_isgreater (data[i].x, data[i].y, data[i].gt);
      test_isgreaterequal (data[i].x, data[i].y, data[i].ge);
      test_islessgreater (data[i].x, data[i].y, data[i].lg);
    }

  exit (0);
}

Here's the catch, when compiling the main function a RECORD_TYPE is built for representing 'struct try' (obviously). Then an helper function is generated which seems to be used for initializing the 'data' array (I think it's called COBJ?Init). A new type still named 'struct try' is used in the COMPONENT_REFs of this function but this type has a different TYPE_UID from the 'struct try' used in main. Since the original type was local to main this makes sense. However this new type shares the fields with the old one i.e. calling DECL_FIELD_CONTEXT () on its fields doesn't yield itself but another type (the old one used in main). Is this correct? The documentation in of DECL_FIELD_CONTEXT () in tree.h doesn't state anything about it which left me kind of confused...

 Gabriele

Reply via email to