re PR c++/60999 (ICE when static_cast from constexpr in specialization of template...
authorPaolo Carlini <paolo.carlini@oracle.com>
Tue, 6 May 2014 22:32:49 +0000 (22:32 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Tue, 6 May 2014 22:32:49 +0000 (22:32 +0000)
/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

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/g++.dg/cpp0x/nsdmi-template10.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp0x/nsdmi-template9.C [new file with mode: 0644]

index dce8df6..d3eb4f2 100644 (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>
index 7e7f6d8..d9e273e 100644 (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))
     {
diff --git a/gcc/testsuite/g++.dg/cpp0x/nsdmi-template10.C b/gcc/testsuite/g++.dg/cpp0x/nsdmi-template10.C
new file mode 100644 (file)
index 0000000..4a8c87e
--- /dev/null
@@ -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;
+  };
+};
diff --git a/gcc/testsuite/g++.dg/cpp0x/nsdmi-template9.C b/gcc/testsuite/g++.dg/cpp0x/nsdmi-template9.C
new file mode 100644 (file)
index 0000000..0cfbb90
--- /dev/null
@@ -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;