[flang-commits] [flang] [flang] Improve error for misplaced statement after CONTAINS in derived type (PR #215886)

via flang-commits flang-commits at lists.llvm.org
Wed Aug 12 18:08:43 PDT 2026


================
@@ -17,10 +19,35 @@ module m
 ! CHECK: error: component definition must precede CONTAINS in a derived type
 ! CHECK-NEXT: {{.*}}real, pointer, dimension(:,:,:), public :: gpoint => null()
      real, pointer, dimension(:,:,:), public :: gpoint => null()
+  end type t1
+
+  ! A second CONTAINS is not a component definition.
+  type :: t2
+   contains
+   contains
+! CHECK: error: expected a type-bound procedure binding (PROCEDURE, GENERIC, or FINAL) after CONTAINS
----------------
mleair wrote:

t1 uses CHECK-NEXT to tie each diagnostic to the exact offending source line. t2, t3, and t4 only check the message text. A regression where the error points to the wrong line would pass undetected. Consider adding CHECK-NEXT lines here as t1 does.

https://github.com/llvm/llvm-project/pull/215886


More information about the flang-commits mailing list