Commit ac054e28 by Joseph Myers Committed by Joseph Myers

c-common.c (expand_tree_builtin): Ensure creal and cimag functions do not return lvalues.

	* c-common.c (expand_tree_builtin): Ensure creal and cimag
	functions do not return lvalues.

testsuite:
	* gcc.dg/builtins-28.c: New test.

From-SVN: r72727
parent d1132e0b
2003-10-20 Joseph S. Myers <jsm@polyomino.org.uk>
* c-common.c (expand_tree_builtin): Ensure creal and cimag
functions do not return lvalues.
2003-10-20 Jason Merrill <jason@redhat.com>
PR c/12553
......
......@@ -3752,14 +3752,16 @@ expand_tree_builtin (tree function, tree params, tree coerced_params)
case BUILT_IN_CREALL:
if (coerced_params == 0)
return integer_zero_node;
return build_unary_op (REALPART_EXPR, TREE_VALUE (coerced_params), 0);
return non_lvalue (build_unary_op (REALPART_EXPR,
TREE_VALUE (coerced_params), 0));
case BUILT_IN_CIMAG:
case BUILT_IN_CIMAGF:
case BUILT_IN_CIMAGL:
if (coerced_params == 0)
return integer_zero_node;
return build_unary_op (IMAGPART_EXPR, TREE_VALUE (coerced_params), 0);
return non_lvalue (build_unary_op (IMAGPART_EXPR,
TREE_VALUE (coerced_params), 0));
case BUILT_IN_ISGREATER:
return expand_unordered_cmp (function, params, UNLE_EXPR, LE_EXPR);
......
2003-10-20 Joseph S. Myers <jsm@polyomino.org.uk>
* gcc.dg/builtins-28.c: New test.
2003-10-20 Jan Hubicka <jh@suse.cz>
* testsuite/g++.dg/opt/inline4.C: Do not use min-inline-insns
......
/* Test that creal and cimag built-in functions do not return lvalues. */
/* Origin: Joseph Myers <jsm@polyomino.org.uk> */
/* { dg-do compile } */
/* { dg-options "" } */
extern float crealf (float _Complex);
extern double creal (double _Complex);
extern long double creall (long double _Complex);
extern float cimagf (float _Complex);
extern double cimag (double _Complex);
extern long double cimagl (long double _Complex);
float _Complex fc;
double _Complex dc;
long double _Complex ldc;
void
foo (void)
{
crealf (fc) = 0; /* { dg-error "lvalue" "crealf not lvalue" } */
cimagf (fc) = 0; /* { dg-error "lvalue" "cimagf not lvalue" } */
creal (dc) = 0; /* { dg-error "lvalue" "creal not lvalue" } */
cimag (dc) = 0; /* { dg-error "lvalue" "cimag not lvalue" } */
creall (ldc) = 0; /* { dg-error "lvalue" "creall not lvalue" } */
cimagl (ldc) = 0; /* { dg-error "lvalue" "cimagl not lvalue" } */
}
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