blob: ebee754f069d6deeb0c27c586938453500cc29af (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
/* APPLE LOCAL file non lvalue assign */
/* { dg-do run } */
/* { dg-options "-fnon-lvalue-assign" } */
#include <stdlib.h>
#define CHECK_IF(expr) if (!(expr)) abort ()
static int global;
void f(int &) { global = 35; }
void f(const int &) { global = 78; }
long long_arr[2];
int main(void) {
char *p;
(long *)p = long_arr; /* { dg-warning "target of assignment not really an lvalue" } */
((long *)p)++; /* { dg-warning "target of assignment not really an lvalue" } */
*(long *)p = -1;
*p = -2;
CHECK_IF(p[-1] == 0 && p[0] == -2 && p[1] == -1);
(long *)p += 2; /* { dg-warning "target of assignment not really an lvalue" } */
(long *)p -= 2; /* { dg-warning "target of assignment not really an lvalue" } */
long x = 0;
f((int)x);
CHECK_IF(global == 78);
return 0;
}
|