[c-family] Small fix for -fdump-ada-spec

Message ID 1644862.nnQPeuc98Z@polaris
State New
Headers show
Series
  • [c-family] Small fix for -fdump-ada-spec
Related show

Commit Message

Eric Botcazou Oct. 1, 2018, 9:39 a.m.
The translation of a pointer to constant value was lacking the package prefix.

Tested on x86_64-suse-linux, applied on the mainline.


2018-10-01  Eric Botcazou  <ebotcazou@adacore.com>

	* c-ada-spec.c (get_underlying_decl): Get to the main type variant.
	(dump_ada_node): Add const keyword.

-- 
Eric Botcazou

Patch

Index: c-ada-spec.c
===================================================================
--- c-ada-spec.c	(revision 264732)
+++ c-ada-spec.c	(working copy)
@@ -1020,13 +1020,18 @@  get_underlying_decl (tree type)
   if (DECL_P (type))
     return type;
 
-  /* type is a typedef.  */
-  if (TYPE_P (type) && TYPE_NAME (type) && DECL_P (TYPE_NAME (type)))
-    return TYPE_NAME (type);
-
-  /* TYPE_STUB_DECL has been set for type.  */
-  if (TYPE_P (type) && TYPE_STUB_DECL (type))
-    return TYPE_STUB_DECL (type);
+  if (TYPE_P (type))
+    {
+      type = TYPE_MAIN_VARIANT (type);
+
+      /* type is a typedef.  */
+      if (TYPE_NAME (type) && DECL_P (TYPE_NAME (type)))
+	return TYPE_NAME (type);
+
+      /* TYPE_STUB_DECL has been set for type.  */
+      if (TYPE_STUB_DECL (type))
+	return TYPE_STUB_DECL (type);
+    }
 
   return NULL_TREE;
 }
@@ -2143,8 +2148,8 @@  dump_ada_node (pretty_printer *buffer, t
 	}
       else
 	{
+	  const unsigned int quals = TYPE_QUALS (TREE_TYPE (node));
 	  bool is_access = false;
-	  unsigned int quals = TYPE_QUALS (TREE_TYPE (node));
 
 	  if (VOID_TYPE_P (TREE_TYPE (node)))
 	    {