gcc/testsuite/g++.dg/ext/builtin-line1.C
raw| 1 | // __builtin_LINE gets the location where the default argument is expanded. |
| 2 | // { dg-do run } |
| 3 | // { dg-skip-if "requires hosted libstdc++ for cassert" { ! hostedlib } } |
| 4 | |
| 5 | #include <cassert> |
| 6 | struct Foo |
| 7 | { |
| 8 | int line; |
| 9 | Foo( int line = __builtin_LINE() ) |
| 10 | : line( line ) |
| 11 | {} |
| 12 | }; |
| 13 | |
| 14 | int main() |
| 15 | { |
| 16 | assert (Foo().line == __LINE__); |
| 17 | assert ((new Foo)->line == __LINE__); |
| 18 | } |