aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2019-08-21 09:54:04 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2019-08-21 09:54:04 +0000
commit8bb2ee59398df615bf4b7c8fa6db2944485e4204 (patch)
treec28df75446d4d16e860e5ad965d3e50549546468 /gcc
parent73c1f2f00e29ead11de64c8131a52cdf33a04897 (diff)
downloadgcc-8bb2ee59398df615bf4b7c8fa6db2944485e4204.zip
gcc-8bb2ee59398df615bf4b7c8fa6db2944485e4204.tar.gz
gcc-8bb2ee59398df615bf4b7c8fa6db2944485e4204.tar.bz2
c-ada-spec.c (dump_ada_function_declaration): Be prepared for broken function declarations where arguments are missing.
* c-ada-spec.c (dump_ada_function_declaration): Be prepared for broken function declarations where arguments are missing. Rename variables. From-SVN: r274794
Diffstat (limited to 'gcc')
-rw-r--r--gcc/c-family/ChangeLog5
-rw-r--r--gcc/c-family/c-ada-spec.c39
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/c-c++-common/dump-ada-spec-15.c6
4 files changed, 36 insertions, 18 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index a4a0bff..c872140 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -1,3 +1,8 @@
+2019-08-21 Eric Botcazou <ebotcazou@adacore.com>
+
+ * c-ada-spec.c (dump_ada_function_declaration): Be prepared for broken
+ function declarations where arguments are missing. Rename variables.
+
2019-08-15 Richard Biener <rguenther@suse.de>
* c-common.c (c_stddef_cpp_builtins): When the GIMPLE FE is
diff --git a/gcc/c-family/c-ada-spec.c b/gcc/c-family/c-ada-spec.c
index 4526850..38d65a6 100644
--- a/gcc/c-family/c-ada-spec.c
+++ b/gcc/c-family/c-ada-spec.c
@@ -1589,14 +1589,13 @@ dump_ada_function_declaration (pretty_printer *buffer, tree func,
bool is_method, bool is_constructor,
bool is_destructor, int spc)
{
- tree arg;
- const tree node = TREE_TYPE (func);
+ tree type = TREE_TYPE (func);
+ tree arg = TYPE_ARG_TYPES (type);
+ tree t;
char buf[17];
- int num = 0, num_args = 0, have_args = true, have_ellipsis = false;
+ int num, num_args = 0, have_args = true, have_ellipsis = false;
/* Compute number of arguments. */
- arg = TYPE_ARG_TYPES (node);
-
if (arg)
{
while (TREE_CHAIN (arg) && arg != error_mark_node)
@@ -1627,25 +1626,29 @@ dump_ada_function_declaration (pretty_printer *buffer, tree func,
pp_left_paren (buffer);
}
+ /* For a function, see if we have the corresponding arguments. */
if (TREE_CODE (func) == FUNCTION_DECL)
- arg = DECL_ARGUMENTS (func);
+ {
+ arg = DECL_ARGUMENTS (func);
+ for (t = arg, num = 0; t; t = DECL_CHAIN (t))
+ num++;
+ if (num < num_args)
+ arg = NULL_TREE;
+ }
else
arg = NULL_TREE;
- if (arg == NULL_TREE)
+ /* Otherwise, only print the types. */
+ if (!arg)
{
have_args = false;
- arg = TYPE_ARG_TYPES (node);
-
- if (arg && TREE_CODE (TREE_VALUE (arg)) == VOID_TYPE)
- arg = NULL_TREE;
+ arg = TYPE_ARG_TYPES (type);
}
if (is_constructor)
arg = TREE_CHAIN (arg);
- /* Print the argument names (if available) & types. */
-
+ /* Print the argument names (if available) and types. */
for (num = 1; num <= num_args; num++)
{
if (have_args)
@@ -1663,13 +1666,13 @@ dump_ada_function_declaration (pretty_printer *buffer, tree func,
pp_string (buffer, buf);
}
- dump_ada_node (buffer, TREE_TYPE (arg), node, spc, false, true);
+ dump_ada_node (buffer, TREE_TYPE (arg), type, spc, false, true);
}
else
{
sprintf (buf, "arg%d : ", num);
pp_string (buffer, buf);
- dump_ada_node (buffer, TREE_VALUE (arg), node, spc, false, true);
+ dump_ada_node (buffer, TREE_VALUE (arg), type, spc, false, true);
}
/* If the type is a pointer to a tagged type, we need to differentiate
@@ -1707,11 +1710,11 @@ dump_ada_function_declaration (pretty_printer *buffer, tree func,
if (num_args > 0)
pp_right_paren (buffer);
- if (is_constructor || !VOID_TYPE_P (TREE_TYPE (node)))
+ if (is_constructor || !VOID_TYPE_P (TREE_TYPE (type)))
{
pp_string (buffer, " return ");
- tree type = is_constructor ? DECL_CONTEXT (func) : TREE_TYPE (node);
- dump_ada_node (buffer, type, type, spc, false, true);
+ tree rtype = is_constructor ? DECL_CONTEXT (func) : TREE_TYPE (type);
+ dump_ada_node (buffer, rtype, rtype, spc, false, true);
}
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 3084456..0bd6133 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2019-08-21 Eric Botcazou <ebotcazou@adacore.com>
+
+ * c-c++-common/dump-ada-spec-15.c: New test.
+
2019-08-21 Christophe Lyon <christophe.lyon@linaro.org>
* gcc.target/arm/cmse/cmse-9.c: Add quotes to expected
diff --git a/gcc/testsuite/c-c++-common/dump-ada-spec-15.c b/gcc/testsuite/c-c++-common/dump-ada-spec-15.c
new file mode 100644
index 0000000..a4b54a6
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/dump-ada-spec-15.c
@@ -0,0 +1,6 @@
+/* { dg-do compile } */
+/* { dg-options "-fdump-ada-spec" } */
+
+extern void (*signal (int __sig, void (*__handler)(int)))(int);
+
+/* { dg-final { cleanup-ada-spec } } */