Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-1645

Code completion doesn't work correctly for nested structs/unions

    XMLWordPrintable

Details

    Description

      I use the following union type (TTestUnion0) often to access the single bits of a byte. In this case, code completion doesn't work correctly, it shows all fields (Bit0, Bit1, Bit2, Bit3, Rest, Bit, Byte) in a flat hierarchy (see attachment).

      However, if I define the Bitfield on it's own (TTestStruct) and use it in a union (TTestUnion1), everything is fine.

      typedef union {
      struct

      { char Bit0: 1; char Bit1: 1; char Bit2: 1; char Bit3: 1; char Rest: 4; }

      Bit;
      char Byte;
      } TTestUnion0;

      typedef struct {
      char Bit0: 1;
      char Bit1: 1;
      char Bit2: 1;
      char Bit3: 1;
      char Rest: 4;
      } TTestStruct;

      typedef union {
      TTestStruct Bit;
      char Byte;
      } TTestUnion1;

      void test()
      {
      TTestUnion0 u0;
      TTestUnion1 u1;

      // completion doesn't work correctly
      u0.Bit0 = 1;

      // completion works!
      u1.Bit.Bit0 = 0;
      u1.Bit.Rest = 4;
      }

      It would be very nice, if this could be improved!

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            con Eike Ziller
            aha_1980 André Hartmann
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes