aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/plugin/diagnostic-test-show-trees-1.c
blob: 7473a07961f2d4811b8eadc0b5081330598545ed (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
65
/* { dg-do compile } */
/* { dg-options "-O -fdiagnostics-show-caret" } */

/* This is an example file for use with
   diagnostic_plugin_show_trees.c.

   The plugin handles "__show_tree" by recursively dumping
   the internal structure of the second input argument.

   We want to accept an expression of any type.  To do this in C, we
   use variadic arguments, but C requires at least one argument before
   the ellipsis, so we have a dummy one.  */

extern void __show_tree (int dummy, ...);

extern double sqrt (double x);

void test_quadratic (double a, double b, double c)
{
  __show_tree (0,
     (-b + sqrt (b * b - 4 * a * c))
     / (2 * a));

/* { dg-begin-multiline-output "" }
      (-b + sqrt (b * b - 4 * a * c))
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      / (2 * a));
      ^~~~~~~~~
   { dg-end-multiline-output "" } */

/* { dg-begin-multiline-output "" }
      (-b + sqrt (b * b - 4 * a * c))
      ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
   { dg-end-multiline-output "" } */

/* { dg-begin-multiline-output "" }
      (-b + sqrt (b * b - 4 * a * c))
            ^~~~~~~~~~~~~~~~~~~~~~~~
   { dg-end-multiline-output "" } */

/* { dg-begin-multiline-output "" }
      (-b + sqrt (b * b - 4 * a * c))
                  ~~~~~~^~~~~~~~~~~
   { dg-end-multiline-output "" } */

/* { dg-begin-multiline-output "" }
      (-b + sqrt (b * b - 4 * a * c))
                  ~~^~~
   { dg-end-multiline-output "" } */

/* { dg-begin-multiline-output "" }
      (-b + sqrt (b * b - 4 * a * c))
                          ~~~~~~^~~
   { dg-end-multiline-output "" } */

/* { dg-begin-multiline-output "" }
      (-b + sqrt (b * b - 4 * a * c))
                          ~~^~~
   { dg-end-multiline-output "" } */

/* { dg-begin-multiline-output "" }
      / (2 * a));
        ~~~^~~~
   { dg-end-multiline-output "" } */
}