Patchwork New command line switch -fada-spec-parent

login
register
mail settings
Submitter Thomas Quinot
Date Aug. 24, 2012, 4:33 p.m.
Message ID <20120824163335.GI7525@melamine.cuivre.fr.eu.org>
Download mbox | patch
Permalink /patch/179873/
State New
Headers show

Comments

Thomas Quinot - Aug. 24, 2012, 4:33 p.m.
The following proposed change adds a new command line switch
-fada-spec-parent allowing the user to specify a parent unit
for all units generated by -fdump-ada-spec.

        * common.opt (-fada-spec-parent): Define new command line switch.
        * c-family/c-ada-spec.c (get_ada_package): When -fada-spec-parent
        is specified, generate binding spec as a child of the specified unit.
        * doc/invoke.texi: Document -fada-spec-parent.

Tested on x86_64-linux.
Steven Bosscher - Aug. 24, 2012, 5:07 p.m.
On Fri, Aug 24, 2012 at 6:33 PM, Thomas Quinot <quinot@adacore.com> wrote:
>         * common.opt (-fada-spec-parent): Define new command line switch.

Why here instead of in c-family/c.opt?
Ciao!
Steven
Thomas Quinot - Aug. 31, 2012, 3:57 p.m.
* Steven Bosscher, 2012-08-24 :

> >         * common.opt (-fada-spec-parent): Define new command line switch.
> Why here instead of in c-family/c.opt?

Makes sense indeed, I'll move the definition there.

Patch

diff --git a/gcc/c-family/c-ada-spec.c b/gcc/c-family/c-ada-spec.c
index d18e78d..250078c 100644
--- a/gcc/c-family/c-ada-spec.c
+++ b/gcc/c-family/c-ada-spec.c
@@ -945,15 +945,26 @@  get_ada_package (const char *file)
   char *res;
   const char *s;
   int i;
+  int plen;
 
   s = strstr (file, "/include/");
   if (s)
     base = s + 9;
   else
     base = lbasename (file);
-  res = XNEWVEC (char, strlen (base) + 1);
 
-  for (i = 0; *base; base++, i++)
+  if (ada_specs_parent == NULL)
+    plen = 0;
+  else
+    plen = strlen(ada_specs_parent) + 1;
+
+  res = XNEWVEC (char, plen + strlen (base) + 1);
+  if (ada_specs_parent != NULL) {
+    strcpy(res, ada_specs_parent);
+    res [plen - 1] = '.';
+  }
+
+  for (i = plen; *base; base++, i++)
     switch (*base)
       {
 	case '+':
@@ -965,7 +976,7 @@  get_ada_package (const char *file)
 	case '_':
 	case '/':
 	case '\\':
-	  res [i] = (i == 0 || res [i - 1] == '_') ? 'u' : '_';
+	  res [i] = (i == 0 || res [i - 1] == '.' || res [i - 1] == '_') ? 'u' : '_';
 	  break;
 
 	default:
@@ -3365,7 +3376,10 @@  dump_ads (const char *source_file,
   ads_name = xstrdup (pkg_name);
 
   for (s = ads_name; *s; s++)
-    *s = TOLOWER (*s);
+    if (*s == '.')
+      *s = '-';
+    else
+      *s = TOLOWER (*s);
 
   ads_name = reconcat (ads_name, ads_name, ".ads", NULL);
 
diff --git a/gcc/common.opt b/gcc/common.opt
index 1c7c4c6..f0fcf5e 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -1031,6 +1031,10 @@  fdump-
 Common Joined RejectNegative Var(common_deferred_options) Defer
 -fdump-<type>	Dump various compiler internals to a file
 
+fada-spec-parent=
+Common RejectNegative Joined Var(ada_specs_parent)
+-fada-spec-parent=unit	Dump Ada specs as child units of given parent
+
 fdump-final-insns
 Driver RejectNegative
 
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 5725f7b..97ac5c3 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -166,7 +166,7 @@  in the following sections.
 -pipe  -pass-exit-codes  @gol
 -x @var{language}  -v  -###  --help@r{[}=@var{class}@r{[},@dots{}@r{]]}  --target-help  @gol
 --version -wrapper @@@var{file} -fplugin=@var{file} -fplugin-arg-@var{name}=@var{arg}  @gol
--fdump-ada-spec@r{[}-slim@r{]} -fdump-go-spec=@var{file}}
+-fdump-ada-spec@r{[}-slim@r{]} -fada-spec-parent=@var{arg} -fdump-go-spec=@var{file}}
 
 @item C Language Options
 @xref{C Dialect Options,,Options Controlling C Dialect}.