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]

[PATCH] Fix PR c++/40557: ICE with template union


Hi all,

Following the fix for PR c++/40007:
   http://gcc.gnu.org/viewcvs?view=rev&revision=147866

this triggers an ICE with the trunk:

=== cut ===
struct A
{
   typedef int X;
};

template<int> union B
{
   A::X x;
};
=== cut ===

This is due to the fix for 40007 checking / asserting
   TREE_CODE (foo) == RECORD_TYPE
instead of
   RECORD_OR_UNION_CODE_P (TREE_CODE (foo))

The attached patch fixes that, which solves the PR. I have successfully
regtested it on x86_64-apple-darwin-9. Is it OK for the trunk?

Best regards,
Simon

:ADDPATCH c++:

2009-07-04  Simon Martin  <simartin@users.sourceforge.net>

	PR c++/40557
	* pt.c (perform_typedefs_access_check, get_types_needing_access_check,
	append_type_to_template_for_access_check_1): Use
	RECORD_OR_UNION_CODE_P.

Index: gcc/cp/pt.c
===================================================================
--- gcc/cp/pt.c	(revision 149223)
+++ gcc/cp/pt.c	(working copy)
@@ -7139,7 +7139,7 @@
   tree t;
 
   if (!tmpl
-      || (TREE_CODE (tmpl) != RECORD_TYPE
+      || (!RECORD_OR_UNION_CODE_P (TREE_CODE (tmpl))
 	  && TREE_CODE (tmpl) != FUNCTION_DECL))
     return;
 
@@ -17509,7 +17509,8 @@
   if (!(ti = get_template_info (t)))
     return NULL_TREE;
 
-  if (TREE_CODE (t) == RECORD_TYPE || TREE_CODE (t) == FUNCTION_DECL)
+  if (RECORD_OR_UNION_CODE_P (TREE_CODE (t))
+      || TREE_CODE (t) == FUNCTION_DECL)
     {
       if (!TI_TEMPLATE (ti))
 	return NULL_TREE;
@@ -17541,7 +17542,7 @@
     return;
 
   gcc_assert ((TREE_CODE (t) == FUNCTION_DECL
-	       || TREE_CODE (t) == RECORD_TYPE)
+	       || RECORD_OR_UNION_CODE_P (TREE_CODE (t)))
 	      && type_decl
 	      && TREE_CODE (type_decl) == TYPE_DECL
 	      && scope);

2009-07-04  Simon Martin  <simartin@users.sourceforge.net>

	PR c++/40557
	* g++.dg/template/union2.C: New test.

/* PR c++/40557 */
/* { dg-do "compile" } */

struct A
{
  typedef int X;
};

template<int> union B
{
  A::X x;
};


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