MikePopoloski / slang

SystemVerilog compiler and language services
MIT License
558 stars 122 forks source link

-Wcomparison-mismatch and enum-value types #1029

Closed jrudess closed 4 days ago

jrudess commented 1 week ago

If an enum-value with a defined type is used in a comparison and that type matches the other side of the comparison, a warning still triggers.

Is it possible to relax the warning for the case of enum-values, or have I missed anything?

slangtest169.sv:12:18: warning: comparison between operands of different types ('int' and 'e_t') [-Wcomparison-mismatch]
        v.size() == E;
        ~~~~~~~~ ^~ ~
class C;

    typedef enum int {
        A = 0,
        C = 2,
        E = 4
    } e_t;

    rand bit v[$];

    constraint q {
        v.size() == E;
    }

endclass
MikePopoloski commented 4 days ago

Done in 4dcf49d00c620686681afbf252c5295fa1f38122