Warnings for input beyond the limits of the Fortran 2023 standard (6.3.2.1): lines longer than 10,000 characters, and statements of more than 1,000,000 characters (counted without comments and line breaks).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | src |
source text |
function limit_diagnostics(src) result(diags) !! Warnings for input beyond the limits of the Fortran 2023 standard (6.3.2.1): lines longer than !! 10,000 characters, and statements of more than 1,000,000 characters (counted without comments !! and line breaks). character(len=*), intent(in) :: src !! source text type(diagnostic_t), allocatable :: diags(:) integer, parameter :: MAX_LINE = 10000, MAX_STATEMENT = 1000000 type(source_t) :: source integer :: k, j, n, line, width, c allocate (diags(0)) if (longest_line(src) > MAX_LINE) then line = 1 width = 0 do k = 1, len(src) c = iand(ichar(src(k:k)), 255) if (c == 10) then line = line + 1 width = 0 else if (c < 128 .or. c >= 192) then width = width + 1 if (width == MAX_LINE + 1) diags = [diags, diagnostic_t(line, 'line '//to_s(line)// & ' is longer than '//to_s(MAX_LINE)//' characters, '// & 'the limit of the Fortran standard')] end if end do end if if (len(src) <= MAX_STATEMENT) return call parse_source(src, source) do k = 1, source%stmts%n if (source%stmts%s(k)%kind /= SK_CODE) cycle n = 0 do j = source%stmts%s(k)%first, source%stmts%s(k)%last associate (t => source%tokens%tok(j)) if (t%kind /= TK_COMMENT .and. t%kind /= TK_NEWLINE) n = n + t%last - t%first + 1 end associate end do if (n > MAX_STATEMENT) then line = source%tokens%tok(source%stmts%s(k)%first)%line diags = [diags, diagnostic_t(line, 'the statement on line '//to_s(line)//' has more than '// & to_s(MAX_STATEMENT)//' characters, the limit of the Fortran standard')] end if end do end function limit_diagnostics