From 25d8f0a2839a99417ab79879fb55f2ead76fcf2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Schl=C3=BCter?= <tobi@gcc.gnu.org> Date: Sun, 30 Oct 2005 19:09:55 +0100 Subject: arith.c (gfc_enum_initializer): New function. fortran/ 2005-10-30 Gaurav Gautam <gauravga@noida.hcltech.com> Tobias Schl"uter <tobias.schlueter@physik.uni-muenchen.de> * arith.c (gfc_enum_initializer): New function. (gfc_check_integer_range): Made extern. * decl.c (enumerator_history): New typedef. (last_initializer, enum_history, max_enum): New variables. (create_enum_history, gfc_free_enum_history): New functions. (add_init_expr_to_sym): Call create_enum_history if parsing ENUM. (variable_decl): Modified to parse enumerator definition. (match_attr_spec): Add PARAMETER attribute to ENUMERATORs. (gfc_match_data_decl): Issues error, if match_type_spec do not return desired return values. (set_enum_kind, gfc_match_enum, gfc_match_enumerator_def): New functions. (gfc_match_end): Deal with END ENUM. * gfortran.h (gfc_statement): ST_ENUM, ST_ENUMERATOR, ST_END_ENUM added. (symbol_attribute): Bit field for enumerator added. (gfc_options): Add fshort_enums. (gfc_enum_initializer, gfc_check_integer_range): Add prototypes. * options.c: Include target.h (gfc_init_options): Initialize fshort_enums. (gfc_handle_option): Deal with fshort_enums. * parse.c (decode_statement): Match ENUM and ENUMERATOR statement. (gfc_ascii_statement): Deal with the enumerator statements. (parse_enum): New function to parse enum construct. (parse_spec): Added case ST_ENUM. * parse.h (gfc_compile_state): COMP_ENUM added. (gfc_match_enum, gfc_match_enumerator_def, gfc_free_enum_history): Prototype added. * symbol.c (gfc_copy_attr): Copy enumeration attribute. * lang.opt (fshort-enums): Option added. testsuite/ 2005-10-30 Tobias Schl"uter <tobias.schlueter@physik.uni-muenchen.de> * gfortran.dg/enum_10.f90, gfortran.dg/enum_10.c: New test. 2005-10-30 Gaurav Gautam <gauravga@noida.hcltech.com> * gfortran.dg/enum_1.f90, gfortran.dg/enum_2.f90, gfortran.dg/enum_3.f90, gfortran.dg/enum_4.f90, gfortran.dg/enum_5.f90, gfortran.dg/enum_6.f90, gfortran.dg/enum_7.f90, gfortran.dg/enum_8.f90, gfortran.dg/enum_9.f90, gfortran.fortran-torture/compile/enum_1.f90, gfortran.fortran-torture/execute/enum_1.f90, gfortran.fortran-torture/execute/enum_2.f90, gfortran.fortran-torture/execute/enum_3.f90, gfortran.fortran-torture/execute/enum_4.f90: New tests. From-SVN: r106246 --- gcc/testsuite/gfortran.dg/enum_10.f90 | 61 +++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/enum_10.f90 (limited to 'gcc/testsuite/gfortran.dg/enum_10.f90') diff --git a/gcc/testsuite/gfortran.dg/enum_10.f90 b/gcc/testsuite/gfortran.dg/enum_10.f90 new file mode 100644 index 00000000000..c3fbe535c4f --- /dev/null +++ b/gcc/testsuite/gfortran.dg/enum_10.f90 @@ -0,0 +1,61 @@ +! { dg-do run } +! { dg-additional-sources enum_10.c } +! { dg-options "-fshort-enums" } +! Make sure short enums are indeed interoperable with the +! corresponding C type. + +module enum_10 +enum, bind( c ) ! { dg-warning "New in Fortran 2003" } + enumerator :: one1 = 1, two1, max1 = huge(1_1) +end enum + +enum, bind( c ) ! { dg-warning "New in Fortran 2003" } + enumerator :: one2 = 1, two2, max2 = huge(1_2) +end enum + +enum, bind( c ) ! { dg-warning "New in Fortran 2003" } + enumerator :: one4 = 1, two4, max4 = huge(1_4) +end enum +end module enum_10 + +use enum_10 + +interface f1 + subroutine f1(i,j) + use enum_10 + integer (kind(max1)) :: i + integer :: j + end subroutine f1 +end interface + + +interface f2 + subroutine f2(i,j) + use enum_10 + integer (kind(max2)) :: i + integer :: j + end subroutine f2 +end interface + + +interface f4 + subroutine f4(i,j) + use enum_10 + integer (kind(max4)) :: i + integer :: j + end subroutine f4 +end interface + + +call f1 (one1, 1) +call f1 (two1, 2) +call f1 (max1, huge(1_1)+0) ! Adding 0 to get default integer + +call f2 (one2, 1) +call f2 (two2, 2) +call f2 (max2, huge(1_2)+0) + +call f4 (one4, 1) +call f4 (two4, 2) +call f4 (max4, huge(1_4)+0) +end -- cgit v1.2.1