libcpp: preserve ranges within macro expansions (PR c++/79300)
[official-gcc.git] / gcc / testsuite / g++.dg / diagnostic / pr79300.C
blob6805e85873ff2951ee099efe33bd5af3bd76ee5a
1 // { dg-options "-fdiagnostics-show-caret" }
3 #define TEST_1_DEPTH_0 throw bad_alloc; // { dg-line define_TEST_1_DEPTH_0 }
5 void test_1 ()
7   TEST_1_DEPTH_0 // { dg-line use_TEST_1_DEPTH_0 }
10 // { dg-error "'bad_alloc' was not declared in this scope" "" { target *-*-* } define_TEST_1_DEPTH_0 }
11 /* { dg-begin-multiline-output "" }
12  #define TEST_1_DEPTH_0 throw bad_alloc;
13                               ^~~~~~~~~
14    { dg-end-multiline-output "" } */
15 // { dg-message "in expansion of macro 'TEST_1_DEPTH_0'" "" { target *-*-* } use_TEST_1_DEPTH_0 }
16 /* { dg-begin-multiline-output "" }
17    TEST_1_DEPTH_0
18    ^~~~~~~~~~~~~~
19    { dg-end-multiline-output "" } */
22 #define TEST_2_DEPTH_0 throw bad_alloc; // { dg-line define_TEST_2_DEPTH_0 }
23 #define TEST_2_DEPTH_1 TEST_2_DEPTH_0 // { dg-line define_TEST_2_DEPTH_1 }
25 void test_2 ()
27   TEST_2_DEPTH_1 // { dg-line use_TEST_2_DEPTH_1 }
30 // { dg-error "'bad_alloc' was not declared in this scope" "" { target *-*-* } define_TEST_2_DEPTH_0 }
31 /* { dg-begin-multiline-output "" }
32  #define TEST_2_DEPTH_0 throw bad_alloc;
33                               ^~~~~~~~~
34    { dg-end-multiline-output "" } */
35 // { dg-message "in expansion of macro 'TEST_2_DEPTH_0'" "" { target *-*-* } define_TEST_2_DEPTH_1 }
36 /* { dg-begin-multiline-output "" }
37  #define TEST_2_DEPTH_1 TEST_2_DEPTH_0
38                         ^~~~~~~~~~~~~~
39    { dg-end-multiline-output "" } */
40 // { dg-message "in expansion of macro 'TEST_2_DEPTH_1'" "" { target *-*-* } use_TEST_2_DEPTH_1 }
41 /* { dg-begin-multiline-output "" }
42    TEST_2_DEPTH_1
43    ^~~~~~~~~~~~~~
44    { dg-end-multiline-output "" } */