diff options
author | Andreas Schwab <schwab@gcc.gnu.org> | 2009-09-27 15:27:08 +0000 |
---|---|---|
committer | Andreas Schwab <schwab@gcc.gnu.org> | 2009-09-27 15:27:08 +0000 |
commit | afbd0665815715ff285dba5143ecb49d4d27990f (patch) | |
tree | c7e4b6907c602b90a4229832311fc15b051f3545 /gcc | |
parent | 88febe351918f2cb70edd3527febf3e06f588089 (diff) | |
download | gcc-afbd0665815715ff285dba5143ecb49d4d27990f.zip gcc-afbd0665815715ff285dba5143ecb49d4d27990f.tar.gz gcc-afbd0665815715ff285dba5143ecb49d4d27990f.tar.bz2 |
re PR c/41476 (__typeof__ expands to const type for function types)
PR c/41476
* c-typeck.c (build_conditional_expr): Use the readonly and
volatile flags of the operand types, not of the operands itself.
testsuite/:
* gcc.dg/cond-constqual-1.c: New test.
From-SVN: r152220
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 16 | ||||
-rw-r--r-- | gcc/c-typeck.c | 8 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/cond-constqual-1.c | 15 |
4 files changed, 36 insertions, 10 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f516f0e..4e9a91b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2009-09-26 Andreas Schwab <schwab@linux-m68k.org> + + PR c/41476 + * c-typeck.c (build_conditional_expr): Use the readonly and + volatile flags of the operand types, not of the operands itself. + 2009-09-25 Peter O'Gorman <pogma@thewrittenword.com> collect2.c (main): Look for -brtl before adding libraries. @@ -130,7 +136,7 @@ (reg_class): Likewise. (REG_CLASS_NAMES): Likewise. * config/m32c/m32c.c (m32c_reg_class_from_constraint): Likewise. - + * config/m32c/m32c.c (m32c_override_options): Disable -fivopts for M32C. @@ -171,7 +177,7 @@ 2009-09-24 Iain Sandoe <iain.sandoe@sandoe-acoustics.co.uk> PR bootstrap/41405 - * common.opt: Initialize dwarf_strict to -1. + * common.opt: Initialize dwarf_strict to -1. * toplev.c (process_options): Catch unset dwarf_strict and set to 0 for all targets not overriding. * config/darwin.c (darwin_override_options): Catch unset @@ -179,7 +185,7 @@ 2009-09-24 Jeff Law <law@redhat.com> - * tree-into-ssa.c (rewrite_into_ssa): Free interesting_blocks. + * tree-into-ssa.c (rewrite_into_ssa): Free interesting_blocks. 2009-09-24 Richard Guenther <rguenther@suse.de> @@ -577,7 +583,7 @@ (TARGET_TRAMPOLINE_INIT): New. (mcore_function_value): Fix typo. (mcore_asm_trampoline_template, mcore_trampoline_init): New. - * config/mcore/mcore.h (TRAMPOLINE_TEMPLATE): Move code + * config/mcore/mcore.h (TRAMPOLINE_TEMPLATE): Move code to mcore_asm_trampoline_template. (INITIALIZE_TRAMPOLINE): Move code to mcore_trampoline_init. @@ -1998,7 +2004,7 @@ * doc/install.texi (avr): Remove obsolete reference site. 2009-09-12 Gerald Pfeifer <gerald@pfeifer.com> - + * doc/install.texi (Binaries): Adjust AIX link. 2009-09-12 Akim Demaille <demaille@gostai.com> diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index 1b2b858..4c55e58 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -4033,12 +4033,12 @@ build_conditional_expr (location_t colon_loc, tree ifexp, bool ifexp_bcp, /* Merge const and volatile flags of the incoming types. */ result_type = build_type_variant (result_type, - TREE_READONLY (op1) || TREE_READONLY (op2), - TREE_THIS_VOLATILE (op1) || TREE_THIS_VOLATILE (op2)); + TYPE_READONLY (type1) || TYPE_READONLY (type2), + TYPE_VOLATILE (type1) || TYPE_VOLATILE (type2)); - if (result_type != TREE_TYPE (op1)) + if (result_type != type1) op1 = convert_and_check (result_type, op1); - if (result_type != TREE_TYPE (op2)) + if (result_type != type2) op2 = convert_and_check (result_type, op2); if (ifexp_bcp && ifexp == truthvalue_true_node) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5f7fdf1..36471f5 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2009-09-26 Andreas Schwab <schwab@linux-m68k.org> + + PR c/41476 + * gcc.dg/cond-constqual-1.c: New test. + 2009-09-26 Michael Matz <matz@suse.de> PR lto/40758 @@ -55,7 +60,7 @@ PR fortran/41459 * gfortran.dg/empty_label.f: New test. * gfortran.dg/empty_label.f90: Ditto. - * gfortran.dg/warnings_are_errors_1.f: Fix to emit a single warning. + * gfortran.dg/warnings_are_errors_1.f: Fix to emit a single warning. 2009-09-24 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> 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 0000000..3354c72 --- /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" } */ +} |