aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/c-c++-common/analyzer/pr96792.c
blob: accaf22ba705b46af4e314b244f9a3c9684daa5a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include "../../gcc.dg/analyzer/analyzer-decls.h"

struct block
{
  void *function;
  const struct block *superblock;
};

struct global_block
{
  struct block block;
  void *compunit_symtab;
};

extern const struct block *block_global_block (const struct block *block);

void *
block_objfile (const struct block *block)
{
  const struct global_block *global_block;

  if (block->function != NULL)
    return block->function;

  global_block = (struct global_block *) block_global_block (block);
  return global_block->compunit_symtab;
}

const struct block *
block_global_block (const struct block *block)
{
  if (block == NULL)
    return NULL;

  while (block->superblock != NULL)
    block = block->superblock;

  return block;
}