Skip to content

Add regression test for designated initializers through anonymous unions #238

Description

@lm-sousa

Clava should add a regression test for designated initializers that select fields through anonymous unions and structs.

This is the exact input used for the corresponding clang-dumper regression test:

struct anonymous_union {
  union {
    int value;
  };
};

struct nested_anonymous_union {
  union {
    struct {
      int value;
    };
  };
};

struct anonymous_union first = { .value = 1 };
struct nested_anonymous_union second = { .value = 2 };

Parse this input with the clang-dumper data and regenerate the code through Clava. The anonymous union and struct declarations should remain anonymous, and the initializers should be reconstructed with the source spelling:

struct anonymous_union first = { .value = 1 };
struct nested_anonymous_union second = { .value = 2 };

In particular, Clava must emit .value, not ..value, for both the direct and nested cases. Formatting may differ, but the designated initializer structure must remain faithful.

The clang-dumper fix is tracked in specs-feup/clang-dumper#48 and PR #49. The producer fix removes synthetic unnamed path entries from the source-level designator list. This issue covers adding the Clava consumer test and confirming that the available data is sufficient for faithful reconstruction.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions