diff options
Diffstat (limited to 'gcc/testsuite/gcc.dg/diagnostic-range-static-assert.c')
-rw-r--r-- | gcc/testsuite/gcc.dg/diagnostic-range-static-assert.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/diagnostic-range-static-assert.c b/gcc/testsuite/gcc.dg/diagnostic-range-static-assert.c new file mode 100644 index 00000000000..6f75476deb3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/diagnostic-range-static-assert.c @@ -0,0 +1,24 @@ +/* { dg-options "-fdiagnostics-show-caret" } */ + +void test_nonconst_static_assert (int param) +{ + int local = 0; + + _Static_assert (param > 0, "message"); /* { dg-error "expression in static assertion is not constant" } */ +/* { dg-begin-multiline-output "" } + _Static_assert (param > 0, "message"); + ~~~~~~^~~ +{ dg-end-multiline-output "" } */ + + _Static_assert (param, "message"); /* { dg-error "expression in static assertion is not constant" } */ +/* { dg-begin-multiline-output "" } + _Static_assert (param, "message"); + ^~~~~ +{ dg-end-multiline-output "" } */ + + _Static_assert (local, "message"); /* { dg-error "expression in static assertion is not constant" } */ +/* { dg-begin-multiline-output "" } + _Static_assert (local, "message"); + ^~~~~ +{ dg-end-multiline-output "" } */ +} |