C/C++: show pertinent open token when missing a close token
[official-gcc.git] / gcc / testsuite / c-c++-common / missing-close-symbol.c
blob85b96f28ef83365845b4face59e5813fbf3cb63b
1 /* { dg-options "-fdiagnostics-show-caret" } */
3 /* Verify that the C/C++ frontends show the pertinent opening symbol when
4 a closing symbol is missing. */
6 /* Verify that, when they are on the same line, that the opening symbol is
7 shown as a secondary range within the main diagnostic. */
9 void test_static_assert_same_line (void)
11 _Static_assert(sizeof(int) >= sizeof(char), "msg"; /* { dg-error "expected '\\)' before ';' token" } */
12 /* { dg-begin-multiline-output "" }
13 _Static_assert(sizeof(int) >= sizeof(char), "msg";
14 ~ ^
15 { dg-end-multiline-output "" } */
18 /* Verify that, when they are on different lines, that the opening symbol is
19 shown via a secondary diagnostic. */
21 void test_static_assert_different_line (void)
23 _Static_assert(sizeof(int) >= sizeof(char), /* { dg-message "to match this '\\('" } */
24 "msg"; /* { dg-error "expected '\\)' before ';' token" } */
25 /* { dg-begin-multiline-output "" }
26 "msg";
28 { dg-end-multiline-output "" } */
29 /* { dg-begin-multiline-output "" }
30 _Static_assert(sizeof(int) >= sizeof(char),
32 { dg-end-multiline-output "" } */