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 for c++/42880


When I reviewed the transparent record patch, I was concerned about using type_as_string, and indeed 42880 is a problem with that usage. So I'm removing it.

I'm not adding a testcase at this time since the actual problem with type_as_string is covered by 42758.

Tested x86_64-pc-linux-gnu, applied to trunk.
commit 24dc5aaad227eb1b054cd933e93fa7ec110b0f6e
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Jan 28 10:00:18 2010 -0500

    	PR c++/42880
    	* semantics.c (begin_class_definition): Don't use type_as_string.

diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index d9ba591..441081c 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -2371,13 +2371,20 @@ begin_class_definition (tree t, tree attributes)
 
   /* According to the C++ ABI, decimal classes defined in ISO/IEC TR 24733
      are passed the same as decimal scalar types.  */
-  if (TREE_CODE (t) == RECORD_TYPE)
+  if (TREE_CODE (t) == RECORD_TYPE
+      && !processing_template_decl)
     {
-      const char *n = type_as_string (t, TFF_CLASS_KEY_OR_ENUM);
-      if ((strcmp (n, "class std::decimal::decimal32") == 0)
-	  || (strcmp (n, "class std::decimal::decimal64") == 0)
-	  || (strcmp (n, "class std::decimal::decimal128") == 0))
-	TYPE_TRANSPARENT_AGGR (t) = 1;
+      tree ns = TYPE_CONTEXT (t);
+      if (ns && TREE_CODE (ns) == NAMESPACE_DECL
+	  && DECL_CONTEXT (ns) == std_node
+	  && !strcmp (IDENTIFIER_POINTER (DECL_NAME (ns)), "decimal"))
+	{
+	  const char *n = TYPE_NAME_STRING (t);
+	  if ((strcmp (n, "decimal32") == 0)
+	      || (strcmp (n, "decimal64") == 0)
+	      || (strcmp (n, "decimal128") == 0))
+	    TYPE_TRANSPARENT_AGGR (t) = 1;
+	}
     }
 
   /* A non-implicit typename comes from code like:

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