public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Warn implicit enum conversions
@ 2004-11-22 15:21 "Richter, Jörg"
  2004-11-22 15:39 ` Giovanni Bajo
  2004-11-22 18:52 ` Giovanni Bajo
  0 siblings, 2 replies; 3+ messages in thread
From: "Richter, Jörg" @ 2004-11-22 15:21 UTC (permalink / raw)
  To: gcc

Hi,

I'm looking for a type attribute for enums which enables warnings when variables of this enum type are implicitly converted to an integral type like int.

I read the online manual and found nothing I could try. 

I can't imagine, that this demand is so uncommon. Perhaps someone knows of a patch that does something like this? Or alternatively you can point me to some functions in gcc where I can start to try to implement it myself?
Ah yes, I need it for C++.


Any help would be greatly appreciated.


   Joerg

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Warn implicit enum conversions
  2004-11-22 15:21 Warn implicit enum conversions "Richter, Jörg"
@ 2004-11-22 15:39 ` Giovanni Bajo
  2004-11-22 18:52 ` Giovanni Bajo
  1 sibling, 0 replies; 3+ messages in thread
From: Giovanni Bajo @ 2004-11-22 15:39 UTC (permalink / raw)
  To: Richter, Jörg; +Cc: gcc

Richter, Jörg <Joerg.Richter@pdv-FS.de> wrote:

> I can't imagine, that this demand is so uncommon. Perhaps someone
> knows of a patch that does something like this? Or alternatively you
> can point me to some functions in gcc where I can start to try to
> implement it myself?
> Ah yes, I need it for C++.

Look into cp/cvt.c, ocp_convert(). It already handles errors for enum to enum
conversion and integer to enum conversion, so you can add your warning there.
Googling a bit should give you at list one link to a patch adding a new warning
message (get something recent!), so that you see all the places you need to
updated.

Remember to work on mainline, not a release branch.

Giovanni Bajo

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Warn implicit enum conversions
  2004-11-22 15:21 Warn implicit enum conversions "Richter, Jörg"
  2004-11-22 15:39 ` Giovanni Bajo
@ 2004-11-22 18:52 ` Giovanni Bajo
  1 sibling, 0 replies; 3+ messages in thread
From: Giovanni Bajo @ 2004-11-22 18:52 UTC (permalink / raw)
  To: Richter, Jörg; +Cc: gcc

Richter, Jörg <Joerg.Richter@pdv-FS.de> wrote:

> I can't imagine, that this demand is so uncommon. Perhaps someone
> knows of a patch that does something like this? Or alternatively you
> can point me to some functions in gcc where I can start to try to
> implement it myself?
> Ah yes, I need it for C++.

Look into cp/cvt.c, ocp_convert(). It already handles errors for enum to enum
conversion and integer to enum conversion, so you can add your warning there.
Googling a bit should give you at list one link to a patch adding a new warning
message (get something recent!), so that you see all the places you need to
updated.

Remember to work on mainline, not a release branch.

Giovanni Bajo

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-11-22 15:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-11-22 15:21 Warn implicit enum conversions "Richter, Jörg"
2004-11-22 15:39 ` Giovanni Bajo
2004-11-22 18:52 ` Giovanni Bajo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).