[Bug c/78736] enum warnings in GCC (request for -Wenum-conversion to be added)

2023-07-02 Thread bp at alien8 dot de via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78736

Boris  changed:

   What|Removed |Added

 CC||bp at alien8 dot de

--- Comment #20 from Boris  ---
(In reply to prathamesh3492 from comment #14)
> The patch enables warning with Wextra due to PR91593 and warnings with
> allmodconfig kernel build. Once these issues are resolved, we could
> consider promoting it to Wall.

Yes, you should. I just built 6.4 allmodconfig and there are no warnings
anymore likely because clang enables this warning by default and since we build
the kernel with both compilers, people have fixed them all in the meantime.

And clang did catch a legitimate error with this warning here while gcc didn't
using the default warning flags but it warned with -Wextra.

So I think we'll enable that warning by default in the kernel build and it does
make sense to do that in gcc too, I'd say.

Thx.

[Bug c/78736] enum warnings in GCC (request for -Wenum-conversion to be added)

2019-10-19 Thread jg at jguk dot org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78736

--- Comment #19 from Jonny Grant  ---
(In reply to Eric Gallager from comment #18)
> (In reply to Jonny Grant from comment #17)
> > Hello Joseph
> > 
> > This was the test case I created. There isn't any warning output when 'a_t'
> > is converted to 'int'. Or even if it was converted to an 'unsigned int'
> > 
> > https://gcc.gnu.org/ml/gcc-help/2019-07/msg00014.html
> > 
> > 
> > //-O2 -Wall -Wextra -Wconversion -Werror
> > 
> > #include 
> > typedef enum
> > {
> > a = -1
> > } a_t;
> > 
> > a_t f()
> > {
> > return a;
> > }
> > 
> > int main()
> > {
> > int b = f();
> > return b;
> > }
> 
> While it's true that g++ prints no warnings for that testcase, I think
> that's material for a separate bug. The original bug here was just to add
> -Wenum-conversion for the C front-end, which has now been done, so I'm
> closing this. Feel free to open new bugs for any missed cases.

ok, I added 
Bug 92159 to add -Wenum-conversion for C++

Bug 92158 my enum test case for C and C++

[Bug c/78736] enum warnings in GCC (request for -Wenum-conversion to be added)

2019-10-18 Thread egallager at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78736

Eric Gallager  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

--- Comment #18 from Eric Gallager  ---
(In reply to Jonny Grant from comment #17)
> Hello Joseph
> 
> This was the test case I created. There isn't any warning output when 'a_t'
> is converted to 'int'. Or even if it was converted to an 'unsigned int'
> 
> https://gcc.gnu.org/ml/gcc-help/2019-07/msg00014.html
> 
> 
> //-O2 -Wall -Wextra -Wconversion -Werror
> 
> #include 
> typedef enum
> {
> a = -1
> } a_t;
> 
> a_t f()
> {
> return a;
> }
> 
> int main()
> {
> int b = f();
> return b;
> }

While it's true that g++ prints no warnings for that testcase, I think that's
material for a separate bug. The original bug here was just to add
-Wenum-conversion for the C front-end, which has now been done, so I'm closing
this. Feel free to open new bugs for any missed cases.

[Bug c/78736] enum warnings in GCC (request for -Wenum-conversion to be added)

2019-09-05 Thread jg at jguk dot org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78736

--- Comment #17 from Jonny Grant  ---
Hello Joseph

This was the test case I created. There isn't any warning output when 'a_t' is
converted to 'int'. Or even if it was converted to an 'unsigned int'

https://gcc.gnu.org/ml/gcc-help/2019-07/msg00014.html


//-O2 -Wall -Wextra -Wconversion -Werror

#include 
typedef enum
{
a = -1
} a_t;

a_t f()
{
return a;
}

int main()
{
int b = f();
return b;
}

[Bug c/78736] enum warnings in GCC (request for -Wenum-conversion to be added)

2019-09-04 Thread joseph at codesourcery dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78736

--- Comment #16 from joseph at codesourcery dot com  ---
Could you give the testcase you expect to be diagnosed with this option 
with C++ that isn't diagnosed by default?

[Bug c/78736] enum warnings in GCC (request for -Wenum-conversion to be added)

2019-09-04 Thread jg at jguk dot org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78736

--- Comment #15 from Jonny Grant  ---
Great this is added for C and ObjC
Could it also be added for C++?

[Bug c/78736] enum warnings in GCC (request for -Wenum-conversion to be added)

2019-09-04 Thread prathamesh3492 at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78736

--- Comment #14 from prathamesh3492 at gcc dot gnu.org ---
Author: prathamesh3492
Date: Wed Sep  4 16:25:21 2019
New Revision: 275376

URL: https://gcc.gnu.org/viewcvs?rev=275376=gcc=rev
Log:
Add warning Wenum-conversion for C and ObjC.

The patch enables warning with Wextra due to PR91593 and warnings with
allmodconfig kernel build. Once these issues are resolved, we could
consider promoting it to Wall.

2019-09-04  Prathamesh Kulkarni  

PR c/78736
* doc/invoke.texi: Document -Wenum-conversion.

c-family
* c.opt (Wenum-conversion): New option.

c/
* c-typeck.c (convert_for_assignment): Handle Wenum-conversion.

testsuite/
* gcc.dg/Wenum-conversion.c: New test-case.

Added:
trunk/gcc/testsuite/gcc.dg/Wenum-conversion.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/c-family/ChangeLog
trunk/gcc/c-family/c.opt
trunk/gcc/c/ChangeLog
trunk/gcc/c/c-typeck.c
trunk/gcc/doc/invoke.texi
trunk/gcc/testsuite/ChangeLog

[Bug c/78736] enum warnings in GCC (request for -Wenum-conversion to be added)

2019-08-28 Thread indan at nul dot nu
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78736

Indan  changed:

   What|Removed |Added

 CC||indan at nul dot nu

--- Comment #13 from Indan  ---
Please implement -Wenum-conversion already, there were working patches for it
in 2017 and now it's 2019!

Just don't enable it by default if that complicates anything.

[Bug c/78736] enum warnings in GCC (request for -Wenum-conversion to be added)

2019-08-02 Thread jg at jguk dot org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78736

--- Comment #12 from Jonny Grant  ---
If -Wenum-conversion is not enabled automatically, do those GCC build warnings
need to be cleaned up before it is added? It's a bit chicken and egg.

[Bug c/78736] enum warnings in GCC (request for -Wenum-conversion to be added)

2019-08-02 Thread joseph at codesourcery dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78736

--- Comment #11 from joseph at codesourcery dot com  ---
Discussions of the change continued into Aug / Sep 2017.  In particular, 
there were issues with warnings this introduced in the GCC build (of 
target libraries), and questions about whether fixes posted for those 
warnings were correct or not.  Did all the warnings this introduced in the 
GCC build get resolved?  If not, those warnings would need dealing with 
first.

[Bug c/78736] enum warnings in GCC (request for -Wenum-conversion to be added)

2019-07-02 Thread jg at jguk dot org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78736

--- Comment #10 from Jonny Grant  ---
Thank you for adding me to the ticket.
I'll add a bounty of $150 for this feature.

Could Prathamesh's change be incorporated?
Thank you, Jonny

[Bug c/78736] enum warnings in GCC (request for -Wenum-conversion to be added)

2019-07-02 Thread egallager at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78736

Eric Gallager  changed:

   What|Removed |Added

 CC||jg at jguk dot org

--- Comment #9 from Eric Gallager  ---
This came up again on gcc-help here:
https://gcc.gnu.org/ml/gcc-help/2019-07/msg00014.html

[Bug c/78736] enum warnings in GCC (request for -Wenum-conversion to be added)

2019-03-31 Thread egallager at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78736

Eric Gallager  changed:

   What|Removed |Added

 Blocks||87403
Summary|enum warnings in GCC|enum warnings in GCC
   ||(request for
   ||-Wenum-conversion to be
   ||added)

--- Comment #8 from Eric Gallager  ---
(In reply to Eric Gallager from comment #7)
> Prathamesh has submitted a patch to the gcc-patches mailing list that still
> needs to be reviewed for this bug:
> https://gcc.gnu.org/ml/gcc-patches/2017-07/msg00514.html

Retitling to clarify which enum warning in particular this bug is about adding


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87403
[Bug 87403] [Meta-bug] Issues that suggest a new warning