Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set ValueType for auto with ternary #5304

Merged
merged 5 commits into from
Aug 18, 2023

Conversation

chrchr-github
Copy link
Collaborator

No description provided.

@chrchr-github
Copy link
Collaborator Author

Not sure if this is/was broken or correct:

static void misra_10_1_ternary(void)
{
    int a;
    uint8_t ui8;
    uint16_t ui16;
    int8_t i8;
    int16_t i16;

    a = ui16 << ui16; // 10.6
    a = ui16 << (get_bool(42) ? ui16 : ui16);
    a = ui16 << (get_bool(42) ? ui16 : (get_bool(34) ? ui16 : ui16)); // 10.4
    a = ui16 << (get_bool(42) ? (get_bool(34) ? ui16 : ui16) : ui16); // 10.4
    a = ui16 << (get_bool(42) ? i16 : (get_bool(34) ? ui16 : ui16)); // 10.1
    a = ui16 << (get_bool(42) ? (get_bool(34) ? ui16 : i16) : ui16); // 10.1 10.4
    a = ui16 << (get_bool(42) ? (get_bool(34) ? ui16 : ui16) : i16); // 10.1
}

@danmar
Copy link
Owner

danmar commented Aug 17, 2023

hmm when I read the misra pdf I think the output is improved. You can change the assertions:

static void misra_10_1_ternary(void)
{
    int a;
    uint8_t ui8;
    uint16_t ui16;
    int8_t i8;
    int16_t i16;

    a = ui16 << ui16; // 10.6
    a = ui16 << (get_bool(42) ? ui16 : ui16);
    a = ui16 << (get_bool(42) ? ui16 : (get_bool(34) ? ui16 : ui16));
    a = ui16 << (get_bool(42) ? (get_bool(34) ? ui16 : ui16) : ui16);
    a = ui16 << (get_bool(42) ? i16 : (get_bool(34) ? ui16 : ui16)); // 10.1 10.4
    a = ui16 << (get_bool(42) ? (get_bool(34) ? ui16 : i16) : ui16); // 10.1 10.4
    a = ui16 << (get_bool(42) ? (get_bool(34) ? ui16 : ui16) : i16); // 10.1 10.4
}

@chrchr-github
Copy link
Collaborator Author

hmm when I read the misra pdf I think the output is improved. You can change the assertions:

Thanks for looking into it, done.

@chrchr-github chrchr-github merged commit 7f22ef4 into danmar:main Aug 18, 2023
72 checks passed
@chrchr-github chrchr-github deleted the chr_autotern branch August 18, 2023 08:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants