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, backport] Ok to backport fix for PR c++/29388 with change?


I would like to backport the patch for PR c++/29388 to the 4.3 branch
but it needs to be changed slightly.  On ToT/4.4 the patch uses
MAYBE_CLASS_TYPE_P which does not exist on the 4.3 branch.  But
IS_AGGR_TYPE does exist and has 'almost' the same definition and even
says to think of it as MAYBE_CLASS_TYPE_P so I would like to just use
that instead.  Does that sound reasonable?

OK to backport the patch with the macro change?

Tested on IA64 HP-UX with no regressions.

Steve Ellcey
sje@cup.hp.com


Original patch submission:
	http://gcc.gnu.org/ml/gcc-patches/2009-01/msg00074.html

Bug URL:
	http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29388



4.3 IS_AGGR_TYPE:

/* Nonzero if T is a class (or struct or union) type.  Also nonzero
   for template type parameters, typename types, and instantiated
   template template parameters.  Despite its name,
   this macro has nothing to do with the definition of aggregate given
   in the standard.  Think of this macro as MAYBE_CLASS_TYPE_P.  Keep
   these checks in ascending code order.  */
#define IS_AGGR_TYPE(T)                                 \
  (TREE_CODE (T) == TEMPLATE_TYPE_PARM                  \
   || TREE_CODE (T) == TYPENAME_TYPE                    \
   || TREE_CODE (T) == TYPEOF_TYPE                      \
   || TREE_CODE (T) == BOUND_TEMPLATE_TEMPLATE_PARM     \
   || TREE_CODE (T) == DECLTYPE_TYPE                    \
   || TYPE_LANG_FLAG_5 (T))



4.4/ToT MAYBE_CLASS_TYPE_P:

/* Nonzero if T is a class (or struct or union) type.  Also nonzero
   for template type parameters, typename types, and instantiated
   template template parameters.  Keep these checks in ascending code
   order.  */
#define MAYBE_CLASS_TYPE_P(T)                                   \
  (TREE_CODE (T) == TEMPLATE_TYPE_PARM                  \
   || TREE_CODE (T) == TYPENAME_TYPE                    \
   || TREE_CODE (T) == TYPEOF_TYPE                      \
   || TREE_CODE (T) == BOUND_TEMPLATE_TEMPLATE_PARM     \ 
   || TREE_CODE (T) == DECLTYPE_TYPE                    \
   || CLASS_TYPE_P (T))
/* Nonzero if T is a class type.  Zero for template type parameters,
   typename types, and so forth.  */
#define CLASS_TYPE_P(T) \
  (RECORD_OR_UNION_CODE_P (TREE_CODE (T)) && TYPE_LANG_FLAG_5 (T))



Here is the actual patch for 4.3 that I would checkin (along with
the test case from the original patch):

Index: decl.c
===================================================================
--- decl.c	(revision 145957)
+++ decl.c	(working copy)
@@ -9115,6 +9115,13 @@ grokdeclarator (const cp_declarator *dec
 		       "declared out of global scope", name);
 	  }
 
+	if (ctype != NULL_TREE
+	    && TREE_CODE (ctype) != NAMESPACE_DECL && !IS_AGGR_TYPE (ctype))
+	  {
+	    error ("%q#T is not a class or a namespace", ctype);
+	    ctype = NULL_TREE;
+	  }
+
 	if (ctype == NULL_TREE)
 	  {
 	    if (virtualp)


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