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
This commit is contained in:
Richard Henderson 2004-08-31 10:39:56 -07:00 committed by Richard Henderson
parent 1c04c4cc03
commit 4bceb077ac
3 changed files with 25 additions and 5 deletions

View File

@ -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.

View File

@ -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);
}

View File

@ -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>;