aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/analyzer/inlining-3-multiline.c
blob: 15a2dd8f0e134ed42bfacc936815d6f3b807b1bc (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/* As per inlining-3.c, but testing how the ASCII art version of
   the path looks.  */

/* { dg-additional-options "-O2 -fdiagnostics-show-path-depths" } */
/* { dg-additional-options "-fdiagnostics-path-format=inline-events -fdiagnostics-show-caret" } */

typedef __SIZE_TYPE__ size_t;
#define NULL ((void *)0)

struct input_file_st 
{
  char inpname[1];
};

typedef struct input_file_st input_file;

static inline const char*
get_input_file_name (const input_file *inpf)
{
  if (inpf)
    return inpf->inpname;
  return NULL;
}

size_t
test (const input_file *inpf)
{
  const char *f = get_input_file_name (inpf);
  return __builtin_strlen (f); /* { dg-warning "use of NULL" "warning" } */
}

/* { dg-begin-multiline-output "" }
   return __builtin_strlen (f);
          ^~~~~~~~~~~~~~~~~~~~
  'test': events 1-2 (depth 1)
    |
    | test (const input_file *inpf)
    | ^~~~
    | |
    | (1) entry to 'test'
    |
    |   const char *f = get_input_file_name (inpf);
    |                   ~
    |                   |
    |                   (2) inlined call to 'get_input_file_name' from 'test'
    |
    +--> 'get_input_file_name': event 3 (depth 2)
           |
           |   if (inpf)
           |      ^
           |      |
           |      (3) following 'false' branch (when 'inpf' is NULL)...
           |
    <------+
    |
  'test': events 4-5 (depth 1)
    |
    |   return __builtin_strlen (f);
    |          ^~~~~~~~~~~~~~~~~~~~
    |          |
    |          (4) ...to here
    |          (5) argument 1 ('<unknown>') NULL where non-null expected
    |
   { dg-end-multiline-output "" } */