view gcc/testsuite/gcc.dg/analyzer/setjmp-8.c @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 1830386684a0
children
line wrap: on
line source

/* { dg-additional-options "-fdiagnostics-show-line-numbers -fdiagnostics-path-format=inline-events -fdiagnostics-show-caret" } */
/* { dg-enable-nn-line-numbers "" } */

#include "test-setjmp.h"
#include <stddef.h>
#include "analyzer-decls.h"

extern int foo (int) __attribute__ ((__pure__));

static jmp_buf env;

static void inner (void)
{
  /* Pass known 0 to longjmp. */
  longjmp (env, 0);
}

void outer (void)
{
  int i;

  foo (0);

  i = SETJMP(env);

  if (i != 0)
    {
      foo (2);
      __analyzer_dump_path (); /* { dg-message "path" } */
    }
  else
    {
      foo (1);
      inner ();
    }
  foo (3);
}

/* { dg-begin-multiline-output "" }
   NN |       __analyzer_dump_path ();
      |       ^~~~~~~~~~~~~~~~~~~~~~~
  'outer': event 1
    |
    |   NN | void outer (void)
    |      |      ^~~~~
    |      |      |
    |      |      (1) entry to 'outer'
    |
  'outer': event 2
    |
    |   NN |   i = SETJMP(env);
    |      |       ^~~~~~
    |      |       |
    |      |       (2) 'setjmp' called here
    |
  'outer': events 3-5
    |
    |   NN |   if (i != 0)
    |      |      ^
    |      |      |
    |      |      (3) following 'false' branch (when 'i == 0')...
    |......
    |   NN |       foo (1);
    |      |       ~~~~~~~
    |      |       |
    |      |       (4) ...to here
    |   NN |       inner ();
    |      |       ~~~~~~~~
    |      |       |
    |      |       (5) calling 'inner' from 'outer'
    |
    +--> 'inner': events 6-7
           |
           |   NN | static void inner (void)
           |      |             ^~~~~
           |      |             |
           |      |             (6) entry to 'inner'
           |......
           |   NN |   longjmp (env, 0);
           |      |   ~~~~~~~~~~~~~~~~
           |      |   |
           |      |   (7) rewinding from 'longjmp' in 'inner'...
           |
    <------+
    |
  'outer': event 8
    |
    |   NN |   i = SETJMP(env);
    |      |       ^~~~~~
    |      |       |
    |      |       (8) ...to 'setjmp' in 'outer' (saved at (2))
    |
  'outer': events 9-11
    |
    |   NN |   if (i != 0)
    |      |      ^
    |      |      |
    |      |      (9) following 'true' branch (when 'i != 0')...
    |   NN |     {
    |   NN |       foo (2);
    |      |       ~~~~~~~
    |      |       |
    |      |       (10) ...to here
    |   NN |       __analyzer_dump_path ();
    |      |       ~~~~~~~~~~~~~~~~~~~~~~~
    |      |       |
    |      |       (11) here
    |
    { dg-end-multiline-output "" } */