aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/lvalue-8.c
blob: 04eeb71b6bca7548876c78bc8a614b16f4226db7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/* 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" } */
}