thradams / cake

Cake a C23 front end and transpiler written in C
http://thradams.com/cake/index.html
GNU General Public License v3.0
544 stars 24 forks source link

New diagnostics mode #112

Closed thradams closed 8 months ago

thradams commented 8 months ago

The idea is to create the concept of diagnostic. User will decide if a message will be an error, warning or note. Se have 3 sets. error,warning, note

if the diagnostic message is not on any of these sets, that means the message is ignored.

mingodad commented 8 months ago

For completeness I propose to also add pedantic as a more strict mode.

thradams commented 8 months ago

the idea is to let user create the sets..using pragma

#pragma warning set "pedantic" "w1, w2"
or 
#define PEDANTIC "w1, w2" //then expand inside pragma (that is uncommon)

then warnings can be set in groups.

for instance (something like, the design is open..)

#pragma warning push "pedantic"
#pragma warning pop

same as

#pragma warning push "w1, w2"
#pragma warning pop
thradams commented 8 months ago

We also need a way to inform if the message is error warning or note.

#pragma warning set "pedantic" "w123, e124, n125"

then 123 is the number of name and w means show as warning, e show as error and n show as note.

thradams commented 8 months ago

Also a way to remove the message from the context. It can be minus sign.

#pragma warning set "no-ownwership-checks" "-241, -454"

#pragma warning push "no-ownwership-checks"
//
#pragma warning pop
thradams commented 8 months ago
void F(int i);
_Owner int make();
int main()
{
    F(make());

#pragma cake diagnostic check "-Wnon-owner-move"
}

new pragma added for unit test.if the last diagnostic is the one informed then the error ir cleared. otherwise an error is added. at the end with this pragma unit test must return no errors. all unit tests must use this.

thradams commented 8 months ago

pragma cake diagnostic check "-Wnon-owner-move" works well for problem in preprocessor and compiler but will not work um analizer . mybe static_state.

but then we have two ways; static_state will no work in preprocessor.

thradams commented 8 months ago

implemented like GCC the only difference is ignore note , that is something below warning.