summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/equiv_constraint_2.f90
diff options
context:
space:
mode:
authorpault <pault@138bc75d-0d04-0410-961f-82ee72b054a4>2005-10-01 07:39:08 +0000
committerpault <pault@138bc75d-0d04-0410-961f-82ee72b054a4>2005-10-01 07:39:08 +0000
commit9e25b302b728aeda854b69c0fc95971e4f3b0980 (patch)
tree4f7afb184987461657573418267617d9f5e4ef27 /gcc/testsuite/gfortran.dg/equiv_constraint_2.f90
parent193c2942bdf616be8a9ab205f5076ed5702f2d0a (diff)
downloadgcc-9e25b302b728aeda854b69c0fc95971e4f3b0980.tar.gz
2005-10-01 Paul Thomas <pault@gcc.gnu.org>
PR fortran/16404 PR fortran/20835 PR fortran/20890 PR fortran/20899 PR fortran/20900 PR fortran/20901 PR fortran/20902 * gfortran.h: Prototype for gfc_add_in_equivalence. * match.c (gfc_match_equivalence): Make a structure component an explicit,rather than a syntax, error in an equivalence group. Call gfc_add_in_equivalence to add the constraints imposed in check_conflict. * resolve.c (resolve_symbol): Add constraints: No public structures with private-type components and no public procedures with private-type dummy arguments. (resolve_equivalence_derived): Add constraint that prevents a structure equivalence member from having a default initializer. (sequence_type): New static function to determine whether an object is default numeric, default character, non-default or mixed sequence. Add corresponding enum typespec. (resolve_equivalence): Add constraints to equivalence groups or their members: No more than one initialized member and that different types are not equivalenced for std=f95. All the simple constraints have been moved to check_conflict. * symbol.c (check_conflict): Simple equivalence constraints added, including those removed from resolve_symbol. (gfc_add_in_equivalence): New function to interface calls match_equivalence to check_conflict. 2005-10-01 Paul Thomas <pault@gcc.gnu.org> PR fortran/16404 PR fortran/20835 PR fortran/20890 PR fortran/20899 PR fortran/20900 PR fortran/20901 PR fortran/20902 gfortran.dg/equiv_constraint_1.f90: New test. gfortran.dg/equiv_constraint_2.f90: New test. gfortran.dg/equiv_constraint_3.f90: New test. gfortran.dg/equiv_constraint_4.f90: New test. gfortran.dg/equiv_constraint_5.f90: New test. gfortran.dg/equiv_constraint_6.f90: New test. gfortran.dg/equiv_constraint_7.f90: New test. gfortran.dg/equiv_constraint_8.f90: New test. gfortran.dg/private_type_1.f90: New test. gfortran.dg/private_type_2.f90: New test. gfortran.dg/g77/980628-2.f, 980628-3.f, 980628-9.f, 980628-10.f: Assert std=gnu to permit mixing of types in equivalence statements. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@104850 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/gfortran.dg/equiv_constraint_2.f90')
-rw-r--r--gcc/testsuite/gfortran.dg/equiv_constraint_2.f9074
1 files changed, 74 insertions, 0 deletions
diff --git a/gcc/testsuite/gfortran.dg/equiv_constraint_2.f90 b/gcc/testsuite/gfortran.dg/equiv_constraint_2.f90
new file mode 100644
index 00000000000..2c3578da0d3
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/equiv_constraint_2.f90
@@ -0,0 +1,74 @@
+! { dg-do compile }
+! { dg-options "-std=f95" }
+!
+! PR20901 - Checks resolution of types in EQUIVALENCE statement when
+! f95 standard is imposed.
+!
+! Contributed by Paul Thomas <pault@gcc.gnu.org>
+!
+ type :: numeric_type
+ sequence
+ integer :: i
+ real :: x
+ real*8 :: d
+ complex :: z
+ logical :: l
+ end type numeric_type
+
+ type (numeric_type) :: my_num, thy_num
+
+ type :: numeric_type2
+ sequence
+ integer :: i
+ real :: x
+ real*8 :: d
+ complex :: z
+ logical :: l
+ end type numeric_type2
+
+ type (numeric_type2) :: his_num
+
+ type :: char_type
+ sequence
+ character*4 :: ch
+ character*4 :: cha (6)
+ end type char_type
+
+ type (char_type) :: my_char
+
+ type :: mixed_type
+ sequence
+ integer*4 :: i(4)
+ character*4 :: cha (6)
+ end type mixed_type
+
+ type (mixed_type) :: my_mixed, thy_mixed
+
+ character(len=4) :: ch
+ integer :: num
+ integer*8 :: non_def
+ complex*16 :: my_z, thy_z
+
+! Permitted: character with character sequence
+! numeric with numeric sequence
+! numeric sequence with numeric sequence
+! non-default of same type
+! mixed sequences of same type
+ equivalence (ch, my_char)
+ equivalence (num, my_num)
+ equivalence (my_num, his_num, thy_num)
+ equivalence (my_z, thy_z)
+ equivalence (my_mixed, thy_mixed)
+
+! Not permitted by the standard - OK with -std=gnu
+ equivalence (my_mixed, my_num) ! { dg-error "with mixed components in EQUIVALENCE" }
+ equivalence (my_z, num) ! { dg-error "Non-default type object or sequence" }
+ equivalence (my_char, my_num) ! { dg-error "in default CHARACTER EQUIVALENCE" }
+ equivalence (ch, my_num) ! { dg-error "in default CHARACTER EQUIVALENCE" }
+ equivalence (my_num, ch) ! { dg-error "in default NUMERIC EQUIVALENCE" }
+ equivalence (num, my_char) ! { dg-error "in default NUMERIC EQUIVALENCE" }
+ equivalence (my_char, num) ! { dg-error "in default CHARACTER EQUIVALENCE" }
+ equivalence (non_def, ch) ! { dg-error "Non-default type object or sequence" }
+ equivalence (my_z, ch) ! { dg-error "Non-default type object or sequence" }
+ equivalence (my_z, num) ! { dg-error "Non-default type object or sequence" }
+ END