URL
https://opencores.org/ocsvn/openrisc/openrisc/trunk
Subversion Repositories openrisc
[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gfortran.dg/] [extends_2.f03] - Rev 694
Compare with Previous | Blame | View Log
! { dg-do run }! A test of f95 style constructors with derived type extension.!! Contributed by Paul Thomas <pault@gcc.gnu.org>!module personstype :: personcharacter(24) :: name = ""integer :: ss = 1end type personend module personsmodule person_educationuse personstype, extends(person) :: educationinteger :: attainment = 0character(24) :: institution = ""end type educationend module person_educationuse person_educationtype, extends(education) :: serviceinteger :: personnel_number = 0character(24) :: department = ""end type servicetype, extends(service) :: person_recordtype (person_record), pointer :: supervisor => NULL ()end type person_recordtype(person_record), pointer :: recruit, supervisor! Check that simple constructor worksallocate (supervisor)supervisor%service = service ("Joe Honcho", 123455, 100, &"Celestial University", 1, &"Directorate")recruit => entry ("John Smith", 123456, 1, "Bog Hill High School", &99, "Records", supervisor)if (trim (recruit%name) /= "John Smith") call abortif (recruit%name /= recruit%service%name) call abortif (recruit%supervisor%ss /= 123455) call abortif (recruit%supervisor%ss /= supervisor%person%ss) call abortdeallocate (supervisor)deallocate (recruit)containsfunction entry (name, ss, attainment, institution, &personnel_number, department, supervisor) result (new_person)integer :: ss, attainment, personnel_numbercharacter (*) :: name, institution, departmenttype (person_record), pointer :: supervisor, new_personallocate (new_person)! Check nested constructorsnew_person = person_record (education (person (name, ss), &attainment, institution), &personnel_number, department, &supervisor)end functionend! { dg-final { cleanup-modules "persons person_education" } }
