diff options
Diffstat (limited to 'gcc')
| -rw-r--r-- | gcc/c-family/c-common.cc | 10 | ||||
| -rw-r--r-- | gcc/testsuite/gcc.dg/complex-10.c | 16 |
2 files changed, 26 insertions, 0 deletions
diff --git a/gcc/c-family/c-common.cc b/gcc/c-family/c-common.cc index 22d5116..5acb221 100644 --- a/gcc/c-family/c-common.cc +++ b/gcc/c-family/c-common.cc @@ -7232,6 +7232,16 @@ fold_offsetof (tree expr, tree type, enum tree_code ctx) case ERROR_MARK: return expr; + case REALPART_EXPR: + return fold_offsetof (TREE_OPERAND (expr, 0), type, code); + + case IMAGPART_EXPR: + base = fold_offsetof (TREE_OPERAND (expr, 0), type, code); + if (base == error_mark_node) + return base; + off = TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (TREE_OPERAND (expr, 0)))); + break; + case VAR_DECL: error ("cannot apply %<offsetof%> to static data member %qD", expr); return error_mark_node; diff --git a/gcc/testsuite/gcc.dg/complex-10.c b/gcc/testsuite/gcc.dg/complex-10.c new file mode 100644 index 0000000..b27f91f --- /dev/null +++ b/gcc/testsuite/gcc.dg/complex-10.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "" } */ + +/* PR c/105555 */ + +struct C { + __complex int i; +}; +struct C p[10]; +int *foo1(void) { + return &__real(p->i); +} + +int *foo2(void) { + return &__imag(p->i); +} |
