Commit 525c617d by Jason Merrill Committed by Jason Merrill

re PR c++/46472 ([C++0X] constexpr is not constexpr)

	PR c++/46472
	* method.c (process_subob_fn): Instantiate constexpr templates.
	* optimize.c (maybe_clone_body): Propagate DECL_DECLARED_CONSTEXPR_P.

From-SVN: r170348
parent ceccaacf
2011-02-20 Jason Merrill <jason@redhat.com>
PR c++/46472
* method.c (process_subob_fn): Instantiate constexpr templates.
* optimize.c (maybe_clone_body): Propagate DECL_DECLARED_CONSTEXPR_P.
2011-02-20 Dodji Seketeli <dodji@redhat.com> 2011-02-20 Dodji Seketeli <dodji@redhat.com>
PR c++/46394 PR c++/46394
......
...@@ -941,8 +941,17 @@ process_subob_fn (tree fn, bool move_p, tree *spec_p, bool *trivial_p, ...@@ -941,8 +941,17 @@ process_subob_fn (tree fn, bool move_p, tree *spec_p, bool *trivial_p,
goto bad; goto bad;
} }
if (constexpr_p && !DECL_DECLARED_CONSTEXPR_P (fn)) if (constexpr_p)
*constexpr_p = false; {
/* If this is a specialization of a constexpr template, we need to
force the instantiation now so that we know whether or not it's
really constexpr. */
if (DECL_DECLARED_CONSTEXPR_P (fn) && DECL_TEMPLATE_INSTANTIATION (fn)
&& !DECL_TEMPLATE_INSTANTIATED (fn))
instantiate_decl (fn, /*defer_ok*/false, /*expl_class*/false);
if (!DECL_DECLARED_CONSTEXPR_P (fn))
*constexpr_p = false;
}
return; return;
......
...@@ -256,6 +256,7 @@ maybe_clone_body (tree fn) ...@@ -256,6 +256,7 @@ maybe_clone_body (tree fn)
/* Update CLONE's source position information to match FN's. */ /* Update CLONE's source position information to match FN's. */
DECL_SOURCE_LOCATION (clone) = DECL_SOURCE_LOCATION (fn); DECL_SOURCE_LOCATION (clone) = DECL_SOURCE_LOCATION (fn);
DECL_DECLARED_INLINE_P (clone) = DECL_DECLARED_INLINE_P (fn); DECL_DECLARED_INLINE_P (clone) = DECL_DECLARED_INLINE_P (fn);
DECL_DECLARED_CONSTEXPR_P (clone) = DECL_DECLARED_CONSTEXPR_P (fn);
DECL_COMDAT (clone) = DECL_COMDAT (fn); DECL_COMDAT (clone) = DECL_COMDAT (fn);
DECL_WEAK (clone) = DECL_WEAK (fn); DECL_WEAK (clone) = DECL_WEAK (fn);
......
2011-02-20 Jason Merrill <jason@redhat.com>
* g++.dg/cpp0x/constexpr-synth1.C: New.
2011-02-20 Nicola Pero <nicola.pero@meta-innovation.com> 2011-02-20 Nicola Pero <nicola.pero@meta-innovation.com>
* objc.dg/layout-2.m: New. * objc.dg/layout-2.m: New.
......
// PR c++/46472
// { dg-options -std=c++0x }
template<class T> struct A {
T t;
constexpr A(){}
};
struct B
{
A<int> a;
};
B b;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment