re PR c++/60999 (ICE when static_cast from constexpr in specialization of template-class)

/cp
2014-05-06  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/60999
	* pt.c (maybe_begin_member_template_processing): Use
	uses_template_parms.

/testsuite
2014-05-06  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/60999
	* g++.dg/cpp0x/nsdmi-template9.C: New.
	* g++.dg/cpp0x/nsdmi-template10.C: Likewise.

From-SVN: r210126
This commit is contained in:
Paolo Carlini 2014-05-06 22:32:49 +00:00 committed by Paolo Carlini
parent 659c0e684c
commit 895a5cc06c
4 changed files with 43 additions and 3 deletions

View File

@ -1,3 +1,9 @@
2014-05-06 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/60999
* pt.c (maybe_begin_member_template_processing): Use
uses_template_parms.
2014-05-06 Kenneth Zadeck <zadeck@naturalbridge.com>
Mike Stump <mikestump@comcast.net>
Richard Sandiford <rdsandiford@googlemail.com>

View File

@ -462,9 +462,13 @@ maybe_begin_member_template_processing (tree decl)
bool nsdmi = TREE_CODE (decl) == FIELD_DECL;
if (nsdmi)
decl = (CLASSTYPE_TEMPLATE_INFO (DECL_CONTEXT (decl))
? CLASSTYPE_TI_TEMPLATE (DECL_CONTEXT (decl))
: NULL_TREE);
{
tree ctx = DECL_CONTEXT (decl);
decl = (CLASSTYPE_TEMPLATE_INFO (ctx)
/* Disregard full specializations (c++/60999). */
&& uses_template_parms (ctx)
? CLASSTYPE_TI_TEMPLATE (ctx) : NULL_TREE);
}
if (inline_needs_template_parms (decl, nsdmi))
{

View File

@ -0,0 +1,14 @@
// PR c++/60999
// { dg-do compile { target c++11 } }
struct B
{
template<int N, int M>
struct A;
template<int M>
struct A<1, M>
{
int X = M;
};
};

View File

@ -0,0 +1,16 @@
// PR c++/60999
// { dg-do compile { target c++11 } }
template <typename A>
struct foo
{
};
template<>
struct foo<int>
{
static constexpr int code = 42;
unsigned int bar = static_cast<unsigned int>(code);
};
foo<int> a;