From: Richard Henderson Date: Tue, 31 Aug 2004 17:39:56 +0000 (-0700) Subject: re PR c++/17221 (C++ offsetof regression) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4bceb077ac4d1b221e4476f988c6717959774d7d;p=gcc.git 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 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index eea871b4c82..2aaca7d43a2 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2004-08-31 Richard Henderson + + PR c++/17221 + * pt.c (tsubst_expr): Move OFFSETOF_EXPR handling ... + (tsubst_copy_and_build): ... here. + 2004-08-30 Mark Mitchell * cp-tree.h (initialize_artificial_var): Declare. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index d7335a06e6b..18f15a890f3 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 00000000000..1ee9be1e31a --- /dev/null +++ b/gcc/testsuite/g++.dg/template/offsetof1.C @@ -0,0 +1,16 @@ +// { dg-do compile } +// PR c++/17221 + +#include + +template struct Bar; +template <> struct Bar<3> {}; + +template +struct Foo { + Bar k; +}; + +struct A { int a; }; + +template struct Foo;