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
This commit is contained in:
Andreas Schwab 2009-09-27 15:27:08 +00:00
parent 88febe3519
commit afbd066581
4 changed files with 36 additions and 10 deletions

View File

@ -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>

View File

@ -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)

View File

@ -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>

View File

@ -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" } */
}