A Power AIX build with fortran enabled fails in stage2, because longjmp
is not declared noreturn in system header files.  That is probably only
true on systems where gcc is the system compiler, since this is a GCC
extension.

.../../gcc-git/gcc/fortran/parse.c: In function 'void unexpected_eof()':
.../../gcc-git/gcc/fortran/parse.c:2740:1: error: 'noreturn' function
does return [-Werror]
 }
  ^

If I drop ATTRIBUTE_NORETURN on the unexpected_eof declaration, then I
get 18 errors that look like this one.  This is stage2 of a linux
build.

.../../gcc-svn/gcc/fortran/parse.c: In function ‘gfc_statement
parse_spec(gfc_statement)’:
.../../gcc-svn/gcc/fortran/parse.c:3745:22: error: this statement may
fall through [-Werror=implicit-fallthrough=]
       unexpected_eof ();
       ~~~~~~~~~~~~~~~^~
.../../gcc-svn/gcc/fortran/parse.c:3747:5: note: here
     case ST_IMPLICIT_NONE:
     ^~~~

If I add a call to gcc_unreachable after the longjmp call, then it
builds on both linux and AIX.  Anyone have a better idea on how to fix
this?  If I don't get any responses in a few days, I will check it in
under the obvious rule, since it fixes a build failure.

Jim

2017-10-29  Jim Wilson  <wil...@tuliptree.org>

	gcc/fortran/
	* parse.c (unexpected_eof): Call gcc_unreachable before return.

Index: gcc/fortran/parse.c
===================================================================
--- gcc/fortran/parse.c	(revision 254210)
+++ gcc/fortran/parse.c	(working copy)
@@ -2737,6 +2737,9 @@ unexpected_eof (void)
   gfc_done_2 ();
 
   longjmp (eof_buf, 1);
+
+  /* Avoids build error on systems where longjmp is not declared noreturn.  */
+  gcc_unreachable ();
 }
 
 

Reply via email to