view gcc/testsuite/gcc.dg/lvalue-8.c @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 04ced10e8804
children
line wrap: on
line source

/* PR c/66341 */
/* { dg-do compile } */

void
foo (int *p)
{
  p = 0;
  /* A cast does not yield an lvalue.  */
  (int *) p = 0; /* { dg-error "lvalue required as left operand of assignment" } */
  /* A cast to a qualified type has the same effect as a cast
     to the unqualified version of the type.  */
  (int *const) p = 0; /* { dg-error "lvalue required as left operand of assignment" } */
  (int *) (char *) p = 0; /* { dg-error "lvalue required as left operand of assignment" } */
  (int *) (char *) (int *) p = 0; /* { dg-error "lvalue required as left operand of assignment" } */
  (int *) (char *) (int *) (char *) p = 0; /* { dg-error "lvalue required as left operand of assignment" } */
  (int *) (double *) p = 0; /* { dg-error "lvalue required as left operand of assignment" } */
  (int *) (int *) p = 0; /* { dg-error "lvalue required as left operand of assignment" } */
  (int *) (int *const) p = 0; /* { dg-error "lvalue required as left operand of assignment" } */
}