diff options
Diffstat (limited to 'gcc/testsuite/gcc.dg/cond-constqual-1.c')
-rw-r--r-- | gcc/testsuite/gcc.dg/cond-constqual-1.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/cond-constqual-1.c b/gcc/testsuite/gcc.dg/cond-constqual-1.c new file mode 100644 index 000000000..3354c7214 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cond-constqual-1.c @@ -0,0 +1,15 @@ +/* Test for const qualification of type of conditional expression. */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +int foo (int) __attribute__ ((const)); +const int i; + +void +test (void) +{ + __typeof__ (1 ? foo (0) : 0) texpr; + __typeof__ (1 ? i : 0) texpr2; + texpr = 0; /* { dg-bogus "read-only variable" "conditional expression with call to const function" } */ + texpr2 = 0; /* { dg-error "read-only variable" "conditional expression with const variable" } */ +} |