Skip to content

Incorrect reference of enum specifier in lazy instantiated variable of the test #600

@IDKWNTCMF

Description

@IDKWNTCMF

Description
If project contains enum with name given by typedef:

typedef enum {
    EVEN,
    ODD
} Parity;

And structs, something like:

struct WrapperStruct {
    Parity p;
};

struct PointerStruct {
    struct WrapperStruct* wrapperStruct;
};

int parityToInt(struct PointerStruct* s) {
    struct WrapperStruct* w = s->wrapperStruct; 
    Parity parity = w->p;
    if (parity == EVEN) {
        return 0;
    }
    return 1;
}

Then generated test can contain lazy instantiated variable:

struct WrapperStruct utbotInnerVar1 = {
    .p = (enum Parity)(507720632)
};

As a result the test cannot be run.

To Reproduce
Steps to reproduce the behavior:

  1. Add example from description in your project.
  2. Generate for function ParityToInt.
  3. See that generated test looks like example above (constant may be different).

Expected behavior
Test is supposed to be generated and executed.

Actual behavior
Test cannot be executed.

Visual proofs (screenshots, logs)

error: typedef 'Parity' cannot be referenced with a enum specifier
        .p = (enum Parity)(507720632)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions