]> git.ipfire.org Git - thirdparty/gcc.git/commit
analyzer: Fix ICE on MD builtin [PR101721]
authorJakub Jelinek <jakub@redhat.com>
Tue, 3 Aug 2021 10:44:17 +0000 (12:44 +0200)
committerJakub Jelinek <jakub@redhat.com>
Tue, 3 Aug 2021 10:44:17 +0000 (12:44 +0200)
commit1a830c0636472e47a7503a5ed879725149e2e728
tree58a8711da5148b4a837d5224c5ebe332dc069120
parent872c1a56e3a08f9e4bb7032b38b0883e8cd7700a
analyzer: Fix ICE on MD builtin [PR101721]

The following testcase ICEs because DECL_FUNCTION_CODE asserts the builtin
is BUILT_IN_NORMAL, but it sees a backend (MD) builtin instead.
The FE, normal and MD builtin numbers overlap, so one should always
check what kind of builtin it is before looking at specific codes.

On the other side, region-model.cc has:
      if (fndecl_built_in_p (callee_fndecl, BUILT_IN_NORMAL)
          && gimple_builtin_call_types_compatible_p (call, callee_fndecl))
        switch (DECL_UNCHECKED_FUNCTION_CODE (callee_fndecl))
which IMO should use DECL_FUNCTION_CODE instead, it checked first it is
a normal builtin...

2021-08-03  Jakub Jelinek  <jakub@redhat.com>

PR analyzer/101721
* sm-malloc.cc (known_allocator_p): Only check DECL_FUNCTION_CODE on
BUILT_IN_NORMAL builtins.

* gcc.dg/analyzer/pr101721.c: New test.
gcc/analyzer/sm-malloc.cc
gcc/testsuite/gcc.dg/analyzer/pr101721.c [new file with mode: 0644]