aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2019-08-22 17:31:02 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2019-08-22 17:31:02 +0000
commitdb376f458e0702a731fc13a62fee5485dca223fe (patch)
tree135da187fcbccffdbb6f1cb7c51166f3ce5d2cb0 /gcc
parent943766d37ae4131aa6cbf9e0b2a660ffea3482a8 (diff)
downloadgcc-db376f458e0702a731fc13a62fee5485dca223fe.zip
gcc-db376f458e0702a731fc13a62fee5485dca223fe.tar.gz
gcc-db376f458e0702a731fc13a62fee5485dca223fe.tar.bz2
c-parser.c (c_parser_declaration_or_fndef): Set DECL_ARGUMENTS of a FUNCTION_DECL to the right value in the presence of...
* c-parser.c (c_parser_declaration_or_fndef): Set DECL_ARGUMENTS of a FUNCTION_DECL to the right value in the presence of nested declarators. From-SVN: r274828
Diffstat (limited to 'gcc')
-rw-r--r--gcc/c/ChangeLog5
-rw-r--r--gcc/c/c-parser.c35
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/c-c++-common/dump-ada-spec-15.c2
4 files changed, 44 insertions, 2 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index 4d2897e..0b3dc74 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -1,3 +1,8 @@
+2019-08-22 Eric Botcazou <ebotcazou@adacore.com>
+
+ * c-parser.c (c_parser_declaration_or_fndef): Set DECL_ARGUMENTS of a
+ FUNCTION_DECL to the right value in the presence of nested declarators.
+
2019-08-13 Richard Sandiford <richard.sandiford@arm.com>
PR middle-end/91421
diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c
index 81919a8..7397f53 100644
--- a/gcc/c/c-parser.c
+++ b/gcc/c/c-parser.c
@@ -2161,10 +2161,41 @@ c_parser_declaration_or_fndef (c_parser *parser, bool fndef_ok,
all_prefix_attrs));
if (d
&& TREE_CODE (d) == FUNCTION_DECL
- && declarator->kind == cdk_function
&& DECL_ARGUMENTS (d) == NULL_TREE
&& DECL_INITIAL (d) == NULL_TREE)
- DECL_ARGUMENTS (d) = declarator->u.arg_info->parms;
+ {
+ /* Find the innermost declarator that is neither cdk_id
+ nor cdk_attrs. */
+ const struct c_declarator *decl = declarator;
+ const struct c_declarator *last_non_id_attrs = NULL;
+
+ while (decl)
+ switch (decl->kind)
+ {
+ case cdk_array:
+ case cdk_function:
+ case cdk_pointer:
+ last_non_id_attrs = decl;
+ decl = decl->declarator;
+ break;
+
+ case cdk_attrs:
+ decl = decl->declarator;
+ break;
+
+ case cdk_id:
+ decl = 0;
+ break;
+
+ default:
+ gcc_unreachable ();
+ }
+
+ /* If it exists and is cdk_function, use its parameters. */
+ if (last_non_id_attrs
+ && last_non_id_attrs->kind == cdk_function)
+ DECL_ARGUMENTS (d) = last_non_id_attrs->u.arg_info->parms;
+ }
if (omp_declare_simd_clauses.exists ())
{
tree parms = NULL_TREE;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 46b63d5..f8a8065 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2019-08-22 Eric Botcazou <ebotcazou@adacore.com>
+
+ * c-c++-common/dump-ada-spec-15.c: Check that the parameters are named.
+
2019-08-22 Kyrylo Tkachov <kyrylo.tkachov@arm.com>
* gcc.target/arm/acle/crc_hf_1.c: New test.
diff --git a/gcc/testsuite/c-c++-common/dump-ada-spec-15.c b/gcc/testsuite/c-c++-common/dump-ada-spec-15.c
index a4b54a6..c51c3e2 100644
--- a/gcc/testsuite/c-c++-common/dump-ada-spec-15.c
+++ b/gcc/testsuite/c-c++-common/dump-ada-spec-15.c
@@ -3,4 +3,6 @@
extern void (*signal (int __sig, void (*__handler)(int)))(int);
+/* { dg-final { scan-ada-spec "uu_sig" } } */
+/* { dg-final { scan-ada-spec "uu_handler" } } */
/* { dg-final { cleanup-ada-spec } } */