From patchwork Fri Aug 24 16:33:35 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: New command line switch -fada-spec-parent Date: Fri, 24 Aug 2012 06:33:35 -0000 From: Thomas Quinot X-Patchwork-Id: 179873 Message-Id: <20120824163335.GI7525@melamine.cuivre.fr.eu.org> To: gcc-patches@gcc.gnu.org, joseph@codesourcery.com Cc: charlet@adacore.com 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. 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- 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}.