re PR c++/35741 (ICE with offsetof and references)
PR c++/35741 * semantics.c (finish_offsetof): Undo effect of convert_from_reference before calling fold_offsetof. * g++.dg/other/offsetof5.C: New test. From-SVN: r133863
This commit is contained in:
parent
6cba282a2c
commit
60c4d1358a
|
@ -1,3 +1,9 @@
|
||||||
|
2008-04-03 Jakub Jelinek <jakub@redhat.com>
|
||||||
|
|
||||||
|
PR c++/35741
|
||||||
|
* semantics.c (finish_offsetof): Undo effect of convert_from_reference
|
||||||
|
before calling fold_offsetof.
|
||||||
|
|
||||||
2008-04-03 Tom Tromey <tromey@redhat.com>
|
2008-04-03 Tom Tromey <tromey@redhat.com>
|
||||||
|
|
||||||
* Make-lang.in (c++_OBJS): New variable.
|
* Make-lang.in (c++_OBJS): New variable.
|
||||||
|
|
|
@ -3039,6 +3039,8 @@ finish_offsetof (tree expr)
|
||||||
error ("cannot apply %<offsetof%> to member function %qD", expr);
|
error ("cannot apply %<offsetof%> to member function %qD", expr);
|
||||||
return error_mark_node;
|
return error_mark_node;
|
||||||
}
|
}
|
||||||
|
if (TREE_CODE (expr) == INDIRECT_REF && REFERENCE_REF_P (expr))
|
||||||
|
expr = TREE_OPERAND (expr, 0);
|
||||||
return fold_offsetof (expr, NULL_TREE);
|
return fold_offsetof (expr, NULL_TREE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
2008-04-03 Jakub Jelinek <jakub@redhat.com>
|
||||||
|
|
||||||
|
PR c++/35741
|
||||||
|
* g++.dg/other/offsetof5.C: New test.
|
||||||
|
|
||||||
2008-04-03 Paolo Bonzini <bonzini@gnu.org>
|
2008-04-03 Paolo Bonzini <bonzini@gnu.org>
|
||||||
|
|
||||||
PR rtl-optimization/35281
|
PR rtl-optimization/35281
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
// PR c++/35741
|
||||||
|
// { dg-do compile }
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
struct A
|
||||||
|
{
|
||||||
|
char c;
|
||||||
|
int &i;
|
||||||
|
};
|
||||||
|
|
||||||
|
int j = offsetof (A, i); // { dg-warning "invalid access|offsetof" }
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct S
|
||||||
|
{
|
||||||
|
T h;
|
||||||
|
T &i;
|
||||||
|
static const int j = offsetof (S, i); // { dg-warning "invalid access|offsetof" }
|
||||||
|
};
|
||||||
|
|
||||||
|
int k = S<int>::j; // { dg-warning "instantiated from here" }
|
Loading…
Reference in New Issue