This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[C++ PATCH] Handle TEMPLATE_PARM_INDEX in finish_decltype_type (PR c++/38640)


Hi!

As shown on the testcase below, TEMPLATE_PARM_INDEX sometimes has
a non-dependent type (integral or pointer), but finish_decltype_type
ICEs in that case (only handles TEMPLATE_PARM_INDEX if it has
dependent type).

Fixed thusly, bootstrapped/regtested on x86_64-linux, ok for trunk?

2008-12-31  Jakub Jelinek  <jakub@redhat.com>

	PR c++/38640
	* semantics.c (finish_decltype_type): Handle TEMPLATE_PARM_INDEX.

	* g++.dg/cpp0x/decltype15.C: New test.

--- gcc/cp/semantics.c.jj	2008-12-30 11:06:58.000000000 +0100
+++ gcc/cp/semantics.c	2008-12-30 16:07:04.000000000 +0100
@@ -4640,6 +4640,7 @@ finish_decltype_type (tree expr, bool id
         case CONST_DECL:
         case PARM_DECL:
         case RESULT_DECL:
+        case TEMPLATE_PARM_INDEX:
           type = TREE_TYPE (expr);
           break;
 
--- gcc/testsuite/g++.dg/cpp0x/decltype15.C.jj	2008-12-30 22:21:30.000000000 +0100
+++ gcc/testsuite/g++.dg/cpp0x/decltype15.C	2008-12-30 22:20:57.000000000 +0100
@@ -0,0 +1,13 @@
+// PR c++/38640
+// { dg-do compile }
+// { dg-options "-std=c++0x" }
+
+template<int N> void foo (decltype (N));
+template<long int N> void foo (decltype (N));
+
+void
+bar (void)
+{
+  foo<5> (6);
+  foo<5L> (6L);
+}

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]