| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-O1 -fdump-tree-dom2 -std=gnu89" } */ |
| 3 |
|
| 4 |
extern void abort (void); |
| 5 |
union tree_node; |
| 6 |
typedef union tree_node *tree; |
| 7 |
|
| 8 |
|
| 9 |
enum tree_code |
| 10 |
{ |
| 11 |
SET_TYPE, |
| 12 |
RECORD_TYPE, |
| 13 |
LAST_AND_UNUSED_TREE_CODE |
| 14 |
}; |
| 15 |
extern const char tree_code_type[]; |
| 16 |
|
| 17 |
struct tree_common |
| 18 |
{ |
| 19 |
|
| 20 |
enum tree_code code:8; |
| 21 |
}; |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
union tree_node |
| 28 |
{ |
| 29 |
struct tree_common common; |
| 30 |
}; |
| 31 |
|
| 32 |
readonly_fields_p (type) |
| 33 |
tree type; |
| 34 |
{ |
| 35 |
|
| 36 |
if (type->common.code != RECORD_TYPE) |
| 37 |
return; |
| 38 |
|
| 39 |
if (tree_code_type[type->common.code] != 't') |
| 40 |
abort (); |
| 41 |
|
| 42 |
return; |
| 43 |
} |
| 44 |
|
| 45 |
/* A good optimizer would realize that the cast to (unsigned int) is |
| 46 |
useless as the earlier cast of the same value of (unsigned char) will |
| 47 |
always produce the same result. */ |
| 48 |
/* { dg-final { scan-tree-dump-times "\\(unsigned int\\)" 0 "dom2"} } */ |
| 49 |
|
| 50 |
/* There should be one load of ->common.code. We currently fail this |
| 51 |
because we load from ->common.code using different types. */ |
| 52 |
/* { dg-final { scan-tree-dump-times "common\.code" 1 "dom2"} } */ |
| 53 |
|