comp.lang.ada
 help / color / mirror / Atom feed
From: ytomino <aghia05@gmail.com>
Subject: Re: gneric package breaks the restriction of No_Elaboration_Code ?
Date: Mon, 7 Mar 2011 00:51:56 -0800 (PST)
Date: 2011-03-07T00:51:56-08:00	[thread overview]
Message-ID: <ab4bf8fe-a9ed-4cae-9a8b-d718eb2d2bfa@y31g2000prd.googlegroups.com> (raw)
In-Reply-To: m2y650z5xk.fsf@pushface.org

On Feb 28, 9:42 pm, Simon Wright <si...@pushface.org> wrote:
> ytomino <aghi...@gmail.com> writes:
> > I think this is gcc's bug. (I tried with gcc-4.5.1/4.5.2)
>
> Same with 4.6.0 experimental at 20110225.

Thanks for confirmation.

I reported this to GCC Bugzilla.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48013

and I made dirty-patch. It tentatively seems correct.
I don't know the details of gcc, cannot judge whether this solution is
correct or ill...
(Most of adainit was decreased with this patch, therefore disused .o
were removed on linking. I'm happy a little... Is it good or bad???)

Index: gcc/ada/gcc-interface/trans.c
===================================================================
--- gcc/ada/gcc-interface/trans.c	(revision 170538)
+++ gcc/ada/gcc-interface/trans.c	(working copy)
@@ -223,6 +223,34 @@
    of configurations.  */
 static const char *extract_encoding (const char *) ATTRIBUTE_UNUSED;
 static const char *decode_name (const char *) ATTRIBUTE_UNUSED;
+
+static bool is_empty (tree x);
+static bool is_empty (tree x)
+{
+  if (x){
+    switch (TREE_CODE (x)){
+    case STATEMENT_LIST:
+      do {
+        struct tree_statement_list_node *i = STATEMENT_LIST_HEAD(x);
+        while (i){
+          if (! is_empty (i->stmt)){
+            return false;
+          }
+          i = i->next;
+        }
+      }while (0);
+      break;
+    case STMT_STMT:
+      if (! is_empty (STMT_STMT_STMT (x))){ /* elm->exp.operands[0]
*/
+        return false;
+      }
+      break;
+    default:
+      return false;
+    }
+  }
+  return true;
+}

 /* This is the main program of the back-end.  It sets up all the
table
    structures and then generates code.  */
@@ -644,7 +672,7 @@
       gnu_stmts = gnu_body;
       if (TREE_CODE (gnu_stmts) == BIND_EXPR)
 	gnu_stmts = BIND_EXPR_BODY (gnu_stmts);
-      if (!gnu_stmts || !STATEMENT_LIST_HEAD (gnu_stmts))
+      if (is_empty (gnu_stmts))
 	Set_Has_No_Elaboration_Code (info->gnat_node, 1);
       else
 	{



  reply	other threads:[~2011-03-07  8:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-28 10:26 gneric package breaks the restriction of No_Elaboration_Code ? ytomino
2011-02-28 12:42 ` Simon Wright
2011-03-07  8:51   ` ytomino [this message]
2011-02-28 13:03 ` ytomino
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox