Commit afbd0665 by Andreas Schwab

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
parent 88febe35
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> 2009-09-25 Peter O'Gorman <pogma@thewrittenword.com>
collect2.c (main): Look for -brtl before adding libraries. collect2.c (main): Look for -brtl before adding libraries.
......
...@@ -4033,12 +4033,12 @@ build_conditional_expr (location_t colon_loc, tree ifexp, bool ifexp_bcp, ...@@ -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. */ /* Merge const and volatile flags of the incoming types. */
result_type result_type
= build_type_variant (result_type, = build_type_variant (result_type,
TREE_READONLY (op1) || TREE_READONLY (op2), TYPE_READONLY (type1) || TYPE_READONLY (type2),
TREE_THIS_VOLATILE (op1) || TREE_THIS_VOLATILE (op2)); TYPE_VOLATILE (type1) || TYPE_VOLATILE (type2));
if (result_type != TREE_TYPE (op1)) if (result_type != type1)
op1 = convert_and_check (result_type, op1); op1 = convert_and_check (result_type, op1);
if (result_type != TREE_TYPE (op2)) if (result_type != type2)
op2 = convert_and_check (result_type, op2); op2 = convert_and_check (result_type, op2);
if (ifexp_bcp && ifexp == truthvalue_true_node) if (ifexp_bcp && ifexp == truthvalue_true_node)
......
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> 2009-09-26 Michael Matz <matz@suse.de>
PR lto/40758 PR lto/40758
......
/* 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" } */
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment