diff options
author | Richard Henderson <rth@redhat.com> | 2004-08-31 10:39:56 -0700 |
---|---|---|
committer | Richard Henderson <rth@gcc.gnu.org> | 2004-08-31 10:39:56 -0700 |
commit | 4bceb077ac4d1b221e4476f988c6717959774d7d (patch) | |
tree | 09aae636ace3dc32a3f2178805e37674692b5413 /gcc | |
parent | 1c04c4cc039e10143d481f328127c601af1d3515 (diff) | |
download | gcc-4bceb077ac4d1b221e4476f988c6717959774d7d.zip gcc-4bceb077ac4d1b221e4476f988c6717959774d7d.tar.gz gcc-4bceb077ac4d1b221e4476f988c6717959774d7d.tar.bz2 |
re PR c++/17221 (C++ offsetof regression)
PR c++/17221
* pt.c (tsubst_expr): Move OFFSETOF_EXPR handling ...
(tsubst_copy_and_build): ... here.
From-SVN: r86835
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/pt.c | 8 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/offsetof1.C | 16 |
3 files changed, 25 insertions, 5 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index eea871b..2aaca7d 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2004-08-31 Richard Henderson <rth@redhat.com> + + PR c++/17221 + * pt.c (tsubst_expr): Move OFFSETOF_EXPR handling ... + (tsubst_copy_and_build): ... here. + 2004-08-30 Mark Mitchell <mark@codesourcery.com> * cp-tree.h (initialize_artificial_var): Declare. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index d7335a0..18f15a8 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -8085,11 +8085,6 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl) tsubst (TREE_TYPE (t), args, complain, NULL_TREE); break; - case OFFSETOF_EXPR: - t = tsubst_copy_and_build (TREE_OPERAND (t, 0), args, complain, - in_decl, false); - return fold_offsetof (t); - default: gcc_assert (!STATEMENT_CODE_P (TREE_CODE (t))); @@ -8630,6 +8625,9 @@ tsubst_copy_and_build (tree t, tsubst_copy (TREE_TYPE (t), args, complain, in_decl)); + case OFFSETOF_EXPR: + return fold_offsetof (RECUR (TREE_OPERAND (t, 0))); + default: return tsubst_copy (t, args, complain, in_decl); } diff --git a/gcc/testsuite/g++.dg/template/offsetof1.C b/gcc/testsuite/g++.dg/template/offsetof1.C new file mode 100644 index 0000000..1ee9be1 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/offsetof1.C @@ -0,0 +1,16 @@ +// { dg-do compile } +// PR c++/17221 + +#include <cstddef> + +template <int N> struct Bar; +template <> struct Bar<3> {}; + +template <class T> +struct Foo { + Bar<offsetof(T, a) + 3> k; +}; + +struct A { int a; }; + +template struct Foo<A>; |