]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c/43384 (ICE: Segmentation fault with invalid K&R-like code)
authorSimon Martin <simartin@users.sourceforge.net>
Sat, 6 Nov 2010 21:58:50 +0000 (21:58 +0000)
committerSimon Martin <simartin@gcc.gnu.org>
Sat, 6 Nov 2010 21:58:50 +0000 (21:58 +0000)
gcc/

2010-11-16  Simon Martin  <simartin@users.sourceforge.net>

PR c/43384
* c-decl.c (lookup_label): Labels can only be referenced in a
function's scope.
(store_parm_decls_oldstyle): Skip erroneous parameters.

gcc/testsuite/

2010-11-16  Simon Martin  <simartin@users.sourceforge.net>

PR c/43384
* gcc.dg/parser-error-3.c: New test.

From-SVN: r166408

gcc/ChangeLog
gcc/c-decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/parse-error-3.c [new file with mode: 0644]

index c214862ce1cd24fd8286e6b7341d3342a28b2371..cb4c17a7ee88d7215426288fc4c646e1afb34bcb 100644 (file)
@@ -1,3 +1,10 @@
+2010-11-06  Simon Martin  <simartin@users.sourceforge.net>
+
+       PR c/43384
+       * c-decl.c (lookup_label): Labels can only be referenced in a
+       function's scope. 
+       (store_parm_decls_oldstyle): Skip erroneous parameters.
+
 2010-11-06  Anatoly Sokolov  <aesok@post.ru>
 
        * config/fr30/fr30.h (FUNCTION_VALUE_REGNO_P, FUNCTION_VALUE,
index 7d27dfe8f0f0078f928381a2adebd3a11556bdb5..e1f14029b80d2e5c733a6757910bd2e5acff4408 100644 (file)
@@ -3013,7 +3013,7 @@ lookup_label (tree name)
   tree label;
   struct c_label_vars *label_vars;
 
-  if (current_function_decl == 0)
+  if (current_function_scope == 0)
     {
       error ("label %qE referenced outside of any function", name);
       return 0;
@@ -7847,6 +7847,9 @@ store_parm_decls_oldstyle (tree fndecl, const struct c_arg_info *arg_info)
       if (b && B_IN_CURRENT_SCOPE (b))
        {
          decl = b->decl;
+         /* Skip erroneous parameters.  */
+         if (decl == error_mark_node)
+           continue;
          /* If we got something other than a PARM_DECL it is an error.  */
          if (TREE_CODE (decl) != PARM_DECL)
            error_at (DECL_SOURCE_LOCATION (decl),
index 911ba14316297ff4a5d67790edd89a95f0fc9205..98a866bb2c5a67450e5756c172c70c3a5e054f9c 100644 (file)
@@ -1,3 +1,8 @@
+2010-11-06  Simon Martin  <simartin@users.sourceforge.net>
+
+       PR c/43384
+       * gcc.dg/parser-error-3.c: New test.
+
 2010-11-06  Nathan Froyd  <froydnj@codesourcery.com>
 
        PR c++/45332
diff --git a/gcc/testsuite/gcc.dg/parse-error-3.c b/gcc/testsuite/gcc.dg/parse-error-3.c
new file mode 100644 (file)
index 0000000..1a463b5
--- /dev/null
@@ -0,0 +1,14 @@
+/* PR c/43384 */
+/* { dg-do "compile" } */
+
+void c_direct(par)
+     void *par = &&lab; /* { dg-error "is initialized|non-standard|outside of" } */
+{}
+
+void foo(p, q)
+     int *p = &q; /* { dg-error "initialized|undeclared" } */
+{}
+
+void bar(i)
+     int j = i; /* { dg-error "initialized|undeclared|no such parameter" } */
+{}