OSDN Git Service

Fix PR c++/41863
authordodji <dodji@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 30 Oct 2009 07:08:36 +0000 (07:08 +0000)
committerdodji <dodji@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 30 Oct 2009 07:08:36 +0000 (07:08 +0000)
gcc/cp/ChangeLog:

PR c++/41863
* pt.c (iterative_hash_template_arg): articifial parms
don't have DECL_PARM_INDEX set. Do not hash it.

gcc/testsuite/ChangeLog:

PR c++/41863
* g++.dg/template/sizeof12.C: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@153735 138bc75d-0d04-0410-961f-82ee72b054a4

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

index 4aec66a..6367f51 100644 (file)
@@ -1,3 +1,9 @@
+2009-10-30  Dodji Seketeli  <dodji@redhat.com>
+
+       PR c++/41863
+       * pt.c (iterative_hash_template_arg): articifial parms
+       don't have DECL_PARM_INDEX set. Do not hash it.
+
 2009-10-28  Jerry Quinn  <jlquinn@optonline.net>
 
        * mangle.c (mangle_type_string_for_rtti): Revert r149964.
index ace340e..9983a95 100644 (file)
@@ -1501,7 +1501,8 @@ iterative_hash_template_arg (tree arg, hashval_t val)
       }
 
     case PARM_DECL:
-      val = iterative_hash_object (DECL_PARM_INDEX (arg), val);
+      if (!DECL_ARTIFICIAL (arg))
+       val = iterative_hash_object (DECL_PARM_INDEX (arg), val);
       return iterative_hash_template_arg (TREE_TYPE (arg), val);
 
     case TARGET_EXPR:
index 044dd74..0df4a2f 100644 (file)
@@ -1,3 +1,8 @@
+2009-10-30  Dodji Seketeli  <dodji@redhat.com>
+
+       PR c++/41863
+       * g++.dg/template/sizeof12.C: New test.
+
 2009-10-29  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gnat.dg/pack14.adb: New test.
diff --git a/gcc/testsuite/g++.dg/template/sizeof12.C b/gcc/testsuite/g++.dg/template/sizeof12.C
new file mode 100644 (file)
index 0000000..e165d2a
--- /dev/null
@@ -0,0 +1,19 @@
+// Contributed by Dodji Seketeli <dodji@redhat.com>
+// Origin PR c++/41863
+
+template<int X>
+struct Bar
+{
+};
+
+template<typename T>
+class Foo
+{
+  T m_foo;
+
+  void
+  crash()
+  {
+    Bar<sizeof(m_foo)> bar;
+  }
+};