diff options
author | Jason Merrill <jason@redhat.com> | 2013-02-14 20:27:36 -0500 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2013-02-14 20:27:36 -0500 |
commit | b24cd3d1f8ab5ad45bafdfd4af0f5805c4788ca2 (patch) | |
tree | 731d3fc809a9c3bd1c51753ad9bee8534d9d9ea2 /gcc | |
parent | d132b74abae28ef6dafb6d194d32c838b204db77 (diff) | |
download | gcc-b24cd3d1f8ab5ad45bafdfd4af0f5805c4788ca2.zip gcc-b24cd3d1f8ab5ad45bafdfd4af0f5805c4788ca2.tar.gz gcc-b24cd3d1f8ab5ad45bafdfd4af0f5805c4788ca2.tar.bz2 |
re PR c++/55003 ([C++11] Member function pointer not working as constexpr initializer)
PR c++/55003
* decl.c (cp_finish_decl): Force instantiation of an
auto static data member.
From-SVN: r196069
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/cp/decl.c | 9 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/auto37.C | 14 |
3 files changed, 27 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 1ecbb7b..1e658e9 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2013-02-14 Jason Merrill <jason@redhat.com> + PR c++/55003 + * decl.c (cp_finish_decl): Force instantiation of an + auto static data member. + PR c++/55220 * pt.c (unify): A pack expansion that is not the last template argument makes the entire template argument list non-deduced. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index eb6c490..3d63389 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -6111,6 +6111,15 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p, tree d_init; if (init == NULL_TREE) { + if (DECL_TEMPLATE_INSTANTIATION (decl) + && !DECL_TEMPLATE_INSTANTIATED (decl)) + { + /* init is null because we're deferring instantiating the + initializer until we need it. Well, we need it now. */ + instantiate_decl (decl, /*defer_ok*/true, /*expl*/false); + return; + } + error ("declaration of %q#D has no initializer", decl); TREE_TYPE (decl) = error_mark_node; return; diff --git a/gcc/testsuite/g++.dg/cpp0x/auto37.C b/gcc/testsuite/g++.dg/cpp0x/auto37.C new file mode 100644 index 0000000..f4b2904 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/auto37.C @@ -0,0 +1,14 @@ +// PR c++/55003 +// { dg-do compile { target c++11 } } + +template<typename T> +struct A { + static const auto t + = (typename T::type)42; +}; + +struct X { + typedef int type; +}; + +A<X> a; |