summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/abstract_type_5.f03
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gfortran.dg/abstract_type_5.f03')
-rw-r--r--gcc/testsuite/gfortran.dg/abstract_type_5.f0346
1 files changed, 46 insertions, 0 deletions
diff --git a/gcc/testsuite/gfortran.dg/abstract_type_5.f03 b/gcc/testsuite/gfortran.dg/abstract_type_5.f03
new file mode 100644
index 000000000..42ac963fa
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/abstract_type_5.f03
@@ -0,0 +1,46 @@
+! { dg-do compile }
+
+! Abstract Types.
+! Check for correct handling of abstract-typed base object references.
+
+MODULE m
+ IMPLICIT NONE
+
+ TYPE, ABSTRACT :: abstract_t
+ INTEGER :: i
+ CONTAINS
+ PROCEDURE, NOPASS :: proc
+ PROCEDURE, NOPASS :: func
+ END TYPE abstract_t
+
+ TYPE, EXTENDS(abstract_t) :: concrete_t
+ END TYPE concrete_t
+
+CONTAINS
+
+ SUBROUTINE proc ()
+ IMPLICIT NONE
+ ! Do nothing
+ END SUBROUTINE proc
+
+ INTEGER FUNCTION func ()
+ IMPLICIT NONE
+ func = 1234
+ END FUNCTION func
+
+ SUBROUTINE test ()
+ IMPLICIT NONE
+ TYPE(concrete_t) :: obj
+
+ ! These are ok.
+ obj%abstract_t%i = 42
+ CALL obj%proc ()
+ PRINT *, obj%func ()
+
+ ! These are errors (even though the procedures are not DEFERRED!).
+ CALL obj%abstract_t%proc () ! { dg-error "is of ABSTRACT type" }
+ PRINT *, obj%abstract_t%func () ! { dg-error "is of ABSTRACT type" }
+ END SUBROUTINE test
+
+END MODULE m
+! { dg-final { cleanup-modules "m" } }