functions do not return lvalues.
testsuite:
* gcc.dg/builtins-28.c: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@72727
138bc75d-0d04-0410-961f-
82ee72b054a4
+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
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
--- /dev/null
+/* 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" } */
+}