]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/57545 (Generation of debug symbols leads to internal compiler error)
authorJason Merrill <jason@redhat.com>
Tue, 9 Jul 2013 17:50:44 +0000 (13:50 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 9 Jul 2013 17:50:44 +0000 (13:50 -0400)
PR c++/57545
* pt.c (convert_nontype_argument) [INTEGER_CST]: Force the
argument to have the exact type of the parameter.

From-SVN: r200831

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/g++.dg/debug/template2.C [new file with mode: 0644]

index f11ad34bc70d0dac456dd814212116683c068576..a9abf59eb7075067786ed01d04c67b9affa6047c 100644 (file)
@@ -1,5 +1,9 @@
 2013-07-09  Jason Merrill  <jason@redhat.com>
 
+       PR c++/57545
+       * pt.c (convert_nontype_argument) [INTEGER_CST]: Force the
+       argument to have the exact type of the parameter.
+
        PR c++/57551
        * semantics.c (cxx_eval_indirect_ref): Don't try to look through
        a POINTER_PLUS_EXPR for type punning diagnostic.
index 7b94e4173517e417ad318e4ef73a546bf3d0da6b..4fbf9d5b98525a0299457db5e0d07791522e05a6 100644 (file)
@@ -5521,6 +5521,10 @@ convert_nontype_argument (tree type, tree expr, tsubst_flags_t complain)
          else
            return NULL_TREE;
        }
+
+      /* Avoid typedef problems.  */
+      if (TREE_TYPE (expr) != type)
+       expr = fold_convert (type, expr);
     }
   /* [temp.arg.nontype]/5, bullet 2
 
diff --git a/gcc/testsuite/g++.dg/debug/template2.C b/gcc/testsuite/g++.dg/debug/template2.C
new file mode 100644 (file)
index 0000000..9f5bcd9
--- /dev/null
@@ -0,0 +1,14 @@
+// PR c++/57545
+
+template<typename T, long unsigned int N>
+struct array {
+    T data[N];
+};
+
+template<typename T>
+struct derived {
+    typedef long unsigned int size_type;
+    static const size_type n = 42;
+
+    array<int, n> a;
+};