re PR c/89211 (ICE in int_mode_for_mode, at stor-layout.c:403)
authorJakub Jelinek <jakub@redhat.com>
Wed, 6 Feb 2019 09:17:55 +0000 (10:17 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 6 Feb 2019 09:17:55 +0000 (10:17 +0100)
PR c/89211
* c-parser.c (c_parser_declaration_or_fndef): Don't update
DECL_ARGUMENTS of d if it has been defined already.  Use a single if
instead of 3 nested ifs.

* gcc.dg/pr89211.c: New test.

From-SVN: r268574

gcc/c/ChangeLog
gcc/c/c-parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr89211.c [new file with mode: 0644]

index 9bb8351cc2ce88a65fdab6a974341e479404eb50..ebe944a57cb2e55da190eff8533f074f0c7e86e2 100644 (file)
@@ -1,3 +1,10 @@
+2019-02-06  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c/89211
+       * c-parser.c (c_parser_declaration_or_fndef): Don't update
+       DECL_ARGUMENTS of d if it has been defined already.  Use a single if
+       instead of 3 nested ifs.
+
 2019-02-06  Joseph Myers  <joseph@codesourcery.com>
 
        PR c/88584
index 76f314e119056544ac365d740459e443f5c6c715..cacbf0ac49564e0186a4acf79e5e753d21e2c369 100644 (file)
@@ -2154,10 +2154,12 @@ c_parser_declaration_or_fndef (c_parser *parser, bool fndef_ok,
              tree d = start_decl (declarator, specs, false,
                                   chainon (postfix_attrs,
                                            all_prefix_attrs));
-             if (d && TREE_CODE (d) == FUNCTION_DECL)
-               if (declarator->kind == cdk_function)
-                 if (DECL_ARGUMENTS (d) == NULL_TREE)
-                   DECL_ARGUMENTS (d) = declarator->u.arg_info->parms;
+             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;
              if (omp_declare_simd_clauses.exists ())
                {
                  tree parms = NULL_TREE;
index b5c92ffb6b6a3a839181f285410493b048bbcc17..e37a94816021c8331c1f765523c0085a76fbe66e 100644 (file)
@@ -1,5 +1,8 @@
 2019-02-06  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c/89211
+       * gcc.dg/pr89211.c: New test.
+
        PR middle-end/89210
        * c-c++-common/builtin-convertvector-2.c: New test.
 
diff --git a/gcc/testsuite/gcc.dg/pr89211.c b/gcc/testsuite/gcc.dg/pr89211.c
new file mode 100644 (file)
index 0000000..cf721aa
--- /dev/null
@@ -0,0 +1,8 @@
+/* PR c/89211 */
+/* { dg-do compile } */
+
+void foo ();
+void foo ()
+{
+  void foo (struct S); /* { dg-warning "declared inside parameter list" } */
+}