+2005-08-24 Thomas Koenig <Thomas.Koenig@online.de>
+
+ PR fortran/17758
+ * gfortran.h (symbol_attribute): Add noreturn to the structure.
+ (gfc_intrinsic_sym): Add noreturn to the structure.
+ * intrinsic.c (make_noreturn): New function.
+ (add_subroutines): Mark subroutines abort and exit as noreturn.
+ (gfc_intrinsic_sub_interface): Copy noreturn attribute from
+ isym to the resolved symbol.
+ * trans-decl.c (gfc_get_extern_function_decl): Set function
+ as VOLATILE (== noreturn) if the noreturn attribute is set.
+
2005-08-21 Steven G. Kargl <kargls@comcast.net>
* decl.c: Typo in comment.
unsigned sequence:1, elemental:1, pure:1, recursive:1;
unsigned unmaskable:1, masked:1, contained:1;
+ /* This is set if the subroutine doesn't return. Currently, this
+ is only possible for intrinsic subroutines. */
+ unsigned noreturn:1;
+
/* Set if this procedure is an alternate entry point. These procedures
don't have any code associated, and the backend will turn them into
thunks to the master function. */
const char *name, *lib_name;
gfc_intrinsic_arg *formal;
gfc_typespec ts;
- int elemental, pure, generic, specific, actual_ok, standard;
+ int elemental, pure, generic, specific, actual_ok, standard, noreturn;
gfc_simplify_f simplify;
gfc_check_f check;
}
}
+/* Make the current subroutine noreturn. */
+
+static void
+make_noreturn(void)
+{
+ if (sizing == SZ_NOTHING)
+ next_sym[-1].noreturn = 1;
+}
/* Add intrinsic functions. */
add_sym_0s ("abort", 1, GFC_STD_GNU, NULL);
+ make_noreturn();
+
add_sym_1s ("cpu_time", 0, 1, BT_UNKNOWN, 0, GFC_STD_F95,
gfc_check_cpu_time, NULL, gfc_resolve_cpu_time,
tm, BT_REAL, dr, REQUIRED);
gfc_check_exit, NULL, gfc_resolve_exit,
c, BT_INTEGER, di, OPTIONAL);
+ make_noreturn();
+
add_sym_1s ("flush", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
gfc_check_flush, NULL, gfc_resolve_flush,
c, BT_INTEGER, di, OPTIONAL);
return MATCH_ERROR;
}
+ c->resolved_sym->attr.noreturn = isym->noreturn;
check_intrinsic_standard (name, isym->standard, &c->loc);
return MATCH_YES;
TREE_SIDE_EFFECTS (fndecl) = 0;
}
+ /* Mark non-returning functions. */
+ if (sym->attr.noreturn)
+ TREE_THIS_VOLATILE(fndecl) = 1;
+
sym->backend_decl = fndecl;
if (DECL_CONTEXT (fndecl) == NULL_TREE)
+2005-08-24 Thomas Koenig <Thomas.Koenig@online.de>
+
+ PR fortran/17758
+ gfortran.dg/nonreturning_statements.f90: New test.
+
2005-08-24 Nathan Sidwell <nathan@codesourcery.com>
PR c++/22454
PR c++/23337
* g++.dg/ext/vector2.C: New.
+2005-08-16 Thomas Koenig <Thomas.Koenig@online.de>
+
+ * gfortran.dg/inquire-complex.f90: Correct mangled testcase.
+
2005-08-16 Thomas Koenig <Thomas.Koenig@online.de>
PR libfortran/23428
--- /dev/null
+! { dg-final { scan-assembler-not "should_be_noreturn" } }
+! PR 17758
+! This checks that non-returning subroutines and statements
+! really don't return by calling non-existing subroutines
+! afterwards. These calls are supposed to be optimized away, so
+! they won't show up in the generated assembly.
+program main
+ character(len=5) :: c
+ c = '12345'
+ read(unit=c,fmt='(A)') i
+ select case(i)
+ case(1)
+ call abort
+ call abort_should_be_noreturn
+ case(2)
+ stop 65
+ call stop_numeric_should_be_noreturn
+ case(3)
+ stop "foobar"
+ call stop_string_should_be_noreturn
+ case(4)
+ call exit
+ call exit_should_be_noreturn
+ end select
+end program main