public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug analyzer/100524] New: pragma GCC diagnostic ignored "-Wanalyzer-too-complex" ignored by cc1
@ 2021-05-11 14:46 andrew at ishiboo dot com
  2021-11-30 19:23 ` [Bug analyzer/100524] " dmalcolm at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: andrew at ishiboo dot com @ 2021-05-11 14:46 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 100524
           Summary: pragma GCC diagnostic ignored "-Wanalyzer-too-complex"
                    ignored by cc1
           Product: gcc
           Version: 11.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: analyzer
          Assignee: dmalcolm at gcc dot gnu.org
          Reporter: andrew at ishiboo dot com
  Target Milestone: ---

Invoking the compiler from the command line as:
  gcc -fanalyzer -Wanalyzer-too-complex -Werror=analyzer-too-complex ...

Source code contains a function that generates a -Wanalyzer-too-complex error
(exact error unimportant):
  ...
  cc1: error: terminating analysis for this program point: callstring: [(SN: 17
-> SN: 9 in X), (SN: 141 -> SN: 16 in X)] before (SN: 115 stmt: 0):  # DEBUG
emptySlots$1 => emptySlots$1_80EN: 973-975, EN: 1017-1018, EN: 1054-1056
[-Werror=analyzer-too-complex]
  test.c: At top level:
  test.c:516:22: error analysis bailed out early (916 'after-snode' enodes;
3258 enodes) [-Werror=analyzer-too-complex]
    516 | ...
        |
  cc1: all warnings being treated as errors

Placing pragma diagnostic guards around the function in question silences the
compiler front-end error, but cc1 still produces the same errors and fails with
-Werror=analyzer-too-complex:

  #pragma diagnostic GCC push
  #pragma diagnostic GCC ignored "-Wanalyzer-too-complex"
  // function definition that generates the error
  #pragma diagnostic GCC pop

Output:
  ...
  cc1: error: terminating analysis for this program point: callstring: [(SN: 17
-> SN: 9 in X), (SN: 141 -> SN: 16 in X)] before (SN: 115 stmt: 0):  # DEBUG
emptySlots$1 => emptySlots$1_80EN: 973-975, EN: 1017-1018, EN: 1054-1056
[-Werror=analyzer-too-complex]
  cc1: all warnings being treated as errors

The "test.c" output with the compiler error and source code context are no
longer output, but cc1 still produces a fatal error and halts compilation.

I would expect that if the warning is `#pragma diagnostic GCC ignored` that cc1
would respect this, otherwise it is not possible to fine-grain ignore specific
complex portions of code in this manner.

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

* [Bug analyzer/100524] pragma GCC diagnostic ignored "-Wanalyzer-too-complex" ignored by cc1
  2021-05-11 14:46 [Bug analyzer/100524] New: pragma GCC diagnostic ignored "-Wanalyzer-too-complex" ignored by cc1 andrew at ishiboo dot com
@ 2021-11-30 19:23 ` dmalcolm at gcc dot gnu.org
  2021-11-30 22:50 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2021-11-30 19:23 UTC (permalink / raw)
  To: gcc-bugs

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

David Malcolm <dmalcolm at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING
   Last reconfirmed|                            |2021-11-30
     Ever confirmed|0                           |1

--- Comment #1 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
Thanks for filing this bug.

Firstly, what you wrote in comment #0 has the directive transposed as:
  #pragma diagnostic GCC [...action...]
whereas the directive should be:
  #pragma GCC diagnostic [...action...]

I've tested the latter with a simple reproducer and verified that I can disable
-Wanalyzer-too-complex with it, whereas the transposed version of the directive
is ignored by GCC and thus does nothing; I'm working on a regression test for
this.

Secondly, there's an issue with source locations in the diagnostic you quoted:
the prefix:
  "cc1: error: "
doesn't contain a source location.  Internally this comes from
diagnostic_build_prefix when the diagnostic's location has a NULL filename,
which is most likely due to a statement with an UNKNOWN_LOCATION.

So the issue is due to a statement in GCC's gimple-ssa IR having
UNKNOWN_LOCATION for its location, which thus doesn't show up within the range
of source locations expressed by the pragma, and thus the diagnostic isn't
affected by the pragmas.

The fix would be to fix the location of the statement in the gimple-ssa IR, but
without a reproducer to identify where that statement's coming from (e.g. in
one of the passes that runs before the analyzer), that's hard to do.

Do you still have the code that reproduces this issue?  (and the precise
optimization flags)

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

* [Bug analyzer/100524] pragma GCC diagnostic ignored "-Wanalyzer-too-complex" ignored by cc1
  2021-05-11 14:46 [Bug analyzer/100524] New: pragma GCC diagnostic ignored "-Wanalyzer-too-complex" ignored by cc1 andrew at ishiboo dot com
  2021-11-30 19:23 ` [Bug analyzer/100524] " dmalcolm at gcc dot gnu.org
@ 2021-11-30 22:50 ` cvs-commit at gcc dot gnu.org
  2021-11-30 23:04 ` dmalcolm at gcc dot gnu.org
  2021-12-01  0:29 ` egallager at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-11-30 22:50 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by David Malcolm <dmalcolm@gcc.gnu.org>:

https://gcc.gnu.org/g:03ea0ca1189a39e095188b0425c66446cc84a0a5

commit r12-5640-g03ea0ca1189a39e095188b0425c66446cc84a0a5
Author: David Malcolm <dmalcolm@redhat.com>
Date:   Tue Nov 30 14:21:31 2021 -0500

    analyzer: verify that -Wanalyzer-too-complex can be disabled via pragmas
[PR100524]

    gcc/testsuite/ChangeLog:
            PR analyzer/100524
            * gcc.dg/analyzer/pragma-2.c: New test.

    Signed-off-by: David Malcolm <dmalcolm@redhat.com>

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

* [Bug analyzer/100524] pragma GCC diagnostic ignored "-Wanalyzer-too-complex" ignored by cc1
  2021-05-11 14:46 [Bug analyzer/100524] New: pragma GCC diagnostic ignored "-Wanalyzer-too-complex" ignored by cc1 andrew at ishiboo dot com
  2021-11-30 19:23 ` [Bug analyzer/100524] " dmalcolm at gcc dot gnu.org
  2021-11-30 22:50 ` cvs-commit at gcc dot gnu.org
@ 2021-11-30 23:04 ` dmalcolm at gcc dot gnu.org
  2021-12-01  0:29 ` egallager at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2021-11-30 23:04 UTC (permalink / raw)
  To: gcc-bugs

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

David Malcolm <dmalcolm at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |RESOLVED
         Resolution|---                         |FIXED

--- Comment #3 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
I've added a regression test for this.

I'm going to mark this as resolved; feel free to reopen it if you can reproduce
the issue (with the preprocessed source and the command-line options); see the
notes in comment #1 above.  Thanks.

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

* [Bug analyzer/100524] pragma GCC diagnostic ignored "-Wanalyzer-too-complex" ignored by cc1
  2021-05-11 14:46 [Bug analyzer/100524] New: pragma GCC diagnostic ignored "-Wanalyzer-too-complex" ignored by cc1 andrew at ishiboo dot com
                   ` (2 preceding siblings ...)
  2021-11-30 23:04 ` dmalcolm at gcc dot gnu.org
@ 2021-12-01  0:29 ` egallager at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: egallager at gcc dot gnu.org @ 2021-12-01  0:29 UTC (permalink / raw)
  To: gcc-bugs

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

Eric Gallager <egallager at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |egallager at gcc dot gnu.org

--- Comment #4 from Eric Gallager <egallager at gcc dot gnu.org> ---
(In reply to David Malcolm from comment #1)
> Firstly, what you wrote in comment #0 has the directive transposed as:
>   #pragma diagnostic GCC [...action...]
> whereas the directive should be:
>   #pragma GCC diagnostic [...action...]

Maybe that itself should be a warning? Does -Wpragmas have anything to say?

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

end of thread, other threads:[~2021-12-01  0:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-11 14:46 [Bug analyzer/100524] New: pragma GCC diagnostic ignored "-Wanalyzer-too-complex" ignored by cc1 andrew at ishiboo dot com
2021-11-30 19:23 ` [Bug analyzer/100524] " dmalcolm at gcc dot gnu.org
2021-11-30 22:50 ` cvs-commit at gcc dot gnu.org
2021-11-30 23:04 ` dmalcolm at gcc dot gnu.org
2021-12-01  0:29 ` egallager at gcc dot gnu.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).