public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/95024] New: No way to pass "-Wno-error=..." with #pragma GCC diagnostic
@ 2020-05-09 19:33 colomar.6.4.3 at gmail dot com
  2020-05-09 20:02 ` [Bug c/95024] " pinskia at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: colomar.6.4.3 at gmail dot com @ 2020-05-09 19:33 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95024

            Bug ID: 95024
           Summary: No way to pass "-Wno-error=..." with #pragma GCC
                    diagnostic
           Product: gcc
           Version: 10.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: colomar.6.4.3 at gmail dot com
  Target Milestone: ---

There is no way to disable `-Werror` for specific lines of code.

I would use something like this:


// I want errors about conversion here

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Werror=conversion"
// I don't want errors about conversion here
#pragma GCC diagnostic push

// I want errors about conversion here

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

* [Bug c/95024] No way to pass "-Wno-error=..." with #pragma GCC diagnostic
  2020-05-09 19:33 [Bug c/95024] New: No way to pass "-Wno-error=..." with #pragma GCC diagnostic colomar.6.4.3 at gmail dot com
@ 2020-05-09 20:02 ` pinskia at gcc dot gnu.org
  2020-05-09 21:30 ` colomar.6.4.3 at gmail dot com
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2020-05-09 20:02 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95024

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |INVALID
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
#pragma GCC diagnostic ignored "-Wconversion"

is what you want.
If you want it the warning still but not erroring out you use:
#pragma GCC diagnostic warning "-Wconversion"


This mentioned in the documentation too.

https://gcc.gnu.org/onlinedocs/gcc-10.1.0/gcc/Diagnostic-Pragmas.html#Diagnostic-Pragmas

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

* [Bug c/95024] No way to pass "-Wno-error=..." with #pragma GCC diagnostic
  2020-05-09 19:33 [Bug c/95024] New: No way to pass "-Wno-error=..." with #pragma GCC diagnostic colomar.6.4.3 at gmail dot com
  2020-05-09 20:02 ` [Bug c/95024] " pinskia at gcc dot gnu.org
@ 2020-05-09 21:30 ` colomar.6.4.3 at gmail dot com
  2020-05-10  1:17 ` pinskia at gcc dot gnu.org
  2024-05-15  6:54 ` [Bug c/95024] want a way to turn off -Werror for a specific diagnostic but only emit an warning if it was turned on before hand alx at kernel dot org
  3 siblings, 0 replies; 5+ messages in thread
From: colomar.6.4.3 at gmail dot com @ 2020-05-09 21:30 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95024

--- Comment #2 from Alejandro Colomar <colomar.6.4.3 at gmail dot com> ---
If I use

#pragma GCC diagnostic ignored "-Wconversion"

I will loose the warning.  I still want the warning, but not the error.
That's what I have right now as a workaround, but it's not what I want.

______

And this:

#pragma GCC diagnostic warning "-Wconversion"

hardcodes the warning.  I want to be able to enable or disable "-Wconversion"
in the command line.

______

There is no way to express that I want to enable or disable a warning/error at
command line, but that some part of the code should never be an error.

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

* [Bug c/95024] No way to pass "-Wno-error=..." with #pragma GCC diagnostic
  2020-05-09 19:33 [Bug c/95024] New: No way to pass "-Wno-error=..." with #pragma GCC diagnostic colomar.6.4.3 at gmail dot com
  2020-05-09 20:02 ` [Bug c/95024] " pinskia at gcc dot gnu.org
  2020-05-09 21:30 ` colomar.6.4.3 at gmail dot com
@ 2020-05-10  1:17 ` pinskia at gcc dot gnu.org
  2024-05-15  6:54 ` [Bug c/95024] want a way to turn off -Werror for a specific diagnostic but only emit an warning if it was turned on before hand alx at kernel dot org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2020-05-10  1:17 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95024

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|INVALID                     |---
             Status|RESOLVED                    |UNCONFIRMED

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Reopening because the original bug report was not clear.

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

* [Bug c/95024] want a way to turn off -Werror for a specific diagnostic but only emit an warning if it was turned on before hand
  2020-05-09 19:33 [Bug c/95024] New: No way to pass "-Wno-error=..." with #pragma GCC diagnostic colomar.6.4.3 at gmail dot com
                   ` (2 preceding siblings ...)
  2020-05-10  1:17 ` pinskia at gcc dot gnu.org
@ 2024-05-15  6:54 ` alx at kernel dot org
  3 siblings, 0 replies; 5+ messages in thread
From: alx at kernel dot org @ 2024-05-15  6:54 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95024

--- Comment #4 from Alejandro Colomar <alx at kernel dot org> ---
Sorry, I didn't make it clear; I somehow forgot about it.

Here's the problem:

$ cat err.c 
int
main(void)
{
        short s;
        int   *p;

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wno-error=incompatible-pointer-types"
        p = &s;
#pragma GCC diagnostic pop
}


$ gcc err.c 
err.c: In function ‘main’:
err.c:8:32: warning: unknown option after ‘#pragma GCC diagnostic’ kind
[-Wpragmas]
    8 | #pragma GCC diagnostic ignored "-Wno-error=incompatible-pointer-types"
      |                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
err.c:8:32: note: did you mean ‘-Wno-incompatible-pointer-types’?
err.c:9:11: warning: assignment to ‘int *’ from incompatible pointer type
‘short int *’ [-Wincompatible-pointer-types]
    9 |         p = &s;
      |           ^

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

end of thread, other threads:[~2024-05-15  6:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-09 19:33 [Bug c/95024] New: No way to pass "-Wno-error=..." with #pragma GCC diagnostic colomar.6.4.3 at gmail dot com
2020-05-09 20:02 ` [Bug c/95024] " pinskia at gcc dot gnu.org
2020-05-09 21:30 ` colomar.6.4.3 at gmail dot com
2020-05-10  1:17 ` pinskia at gcc dot gnu.org
2024-05-15  6:54 ` [Bug c/95024] want a way to turn off -Werror for a specific diagnostic but only emit an warning if it was turned on before hand alx at kernel dot org

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).