re PR c++/38795 (ICE with reinterpret_cast and variadic templates)
authorJakub Jelinek <jakub@redhat.com>
Tue, 13 Jan 2009 18:11:50 +0000 (19:11 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 13 Jan 2009 18:11:50 +0000 (19:11 +0100)
PR c++/38795
* tree.c (cp_walk_subtrees): Handle REINTERPRET_CAST_EXPR,
STATIC_CAST_EXPR, CONST_CAST_EXPR and DYNAMIC_CAST_EXPR the same
as CAST_EXPR.

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

From-SVN: r143351

gcc/cp/ChangeLog
gcc/cp/tree.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/pr38795.C [new file with mode: 0644]

index 7e35ecde16d1b3e23d163b663a3c0ab4370709fa..12c07ee04fe25e995fb1bc891f65ce30e91f9f6e 100644 (file)
@@ -1,3 +1,10 @@
+2009-01-13  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/38795
+       * tree.c (cp_walk_subtrees): Handle REINTERPRET_CAST_EXPR,
+       STATIC_CAST_EXPR, CONST_CAST_EXPR and DYNAMIC_CAST_EXPR the same
+       as CAST_EXPR.
+
 2009-01-12  Jason Merrill  <jason@redhat.com>
            Steve Ellcey  <sje@cup.hp.com>
 
index ad84cc8d8d3f3be7a65bd2e9e9179e3ecf1670ec..8ac272095bef39990fc3a39efab465dd0f16efcc 100644 (file)
@@ -1,6 +1,6 @@
 /* Language-dependent node constructors for parse phase of GNU compiler.
    Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
-   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008
+   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009
    Free Software Foundation, Inc.
    Hacked by Michael Tiemann (tiemann@cygnus.com)
 
@@ -2443,6 +2443,10 @@ cp_walk_subtrees (tree *tp, int *walk_subtrees_p, walk_tree_fn func,
       break;
 
     case CAST_EXPR:
+    case REINTERPRET_CAST_EXPR:
+    case STATIC_CAST_EXPR:
+    case CONST_CAST_EXPR:
+    case DYNAMIC_CAST_EXPR:
       if (TREE_TYPE (*tp))
        WALK_SUBTREE (TREE_TYPE (*tp));
 
index 37223ec2e62c2f72d959f19c7d3eaff975b10802..18f15ca65abdd26c0e38987ad66c35c772af8e71 100644 (file)
@@ -1,3 +1,8 @@
+2009-01-13  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/38795
+       * g++.dg/cpp0x/pr38795.C: New test.
+
 2009-01-13  Daniel Jacobowitz  <dan@codesourcery.com>
            Nathan Froyd  <froydnj@codesourcery.com>
            Joseph Myers  <joseph@codesourcery.com>
diff --git a/gcc/testsuite/g++.dg/cpp0x/pr38795.C b/gcc/testsuite/g++.dg/cpp0x/pr38795.C
new file mode 100644 (file)
index 0000000..54fb361
--- /dev/null
@@ -0,0 +1,13 @@
+// PR c++/38795
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+
+template<typename... T> int foo(int i)
+{
+  return *reinterpret_cast<T*>(i);     // { dg-error "not expanded with|T" }
+}
+
+void bar(int i)
+{
+  foo<int>(i);
+}