diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index dce8df6c286..d3eb4f2e10d 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2014-05-06 Paolo Carlini + + PR c++/60999 + * pt.c (maybe_begin_member_template_processing): Use + uses_template_parms. + 2014-05-06 Kenneth Zadeck Mike Stump Richard Sandiford diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 7e7f6d89f0d..d9e273e78da 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -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)) { diff --git a/gcc/testsuite/g++.dg/cpp0x/nsdmi-template10.C b/gcc/testsuite/g++.dg/cpp0x/nsdmi-template10.C new file mode 100644 index 00000000000..4a8c87e6d87 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/nsdmi-template10.C @@ -0,0 +1,14 @@ +// PR c++/60999 +// { dg-do compile { target c++11 } } + +struct B +{ + template + struct A; + + template + struct A<1, M> + { + int X = M; + }; +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/nsdmi-template9.C b/gcc/testsuite/g++.dg/cpp0x/nsdmi-template9.C new file mode 100644 index 00000000000..0cfbb904424 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/nsdmi-template9.C @@ -0,0 +1,16 @@ +// PR c++/60999 +// { dg-do compile { target c++11 } } + +template +struct foo +{ +}; + +template<> +struct foo +{ + static constexpr int code = 42; + unsigned int bar = static_cast(code); +}; + +foo a;