get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/2217426/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 2217426,
    "url": "http://patchwork.ozlabs.org/api/patches/2217426/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/gcc/patch/50636c8a-9a19-48e1-835a-7024d6dfcc3e@gmail.com/",
    "project": {
        "id": 17,
        "url": "http://patchwork.ozlabs.org/api/projects/17/?format=api",
        "name": "GNU Compiler Collection",
        "link_name": "gcc",
        "list_id": "gcc-patches.gcc.gnu.org",
        "list_email": "gcc-patches@gcc.gnu.org",
        "web_url": null,
        "scm_url": null,
        "webscm_url": null,
        "list_archive_url": "",
        "list_archive_url_format": "",
        "commit_url_format": ""
    },
    "msgid": "<50636c8a-9a19-48e1-835a-7024d6dfcc3e@gmail.com>",
    "list_archive_url": null,
    "date": "2026-03-29T02:38:12",
    "name": "[fortran] Fix Bug 124543 - INQUIRE: Sometimes returns incorrect values",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "e4625be283ad13eb2e214064b1e9cb09ae8c1939",
    "submitter": {
        "id": 78264,
        "url": "http://patchwork.ozlabs.org/api/people/78264/?format=api",
        "name": "Jerry D",
        "email": "jvdelisle2@gmail.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/gcc/patch/50636c8a-9a19-48e1-835a-7024d6dfcc3e@gmail.com/mbox/",
    "series": [
        {
            "id": 497893,
            "url": "http://patchwork.ozlabs.org/api/series/497893/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/gcc/list/?series=497893",
            "date": "2026-03-29T02:38:12",
            "name": "[fortran] Fix Bug 124543 - INQUIRE: Sometimes returns incorrect values",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/497893/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/2217426/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/2217426/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org>",
        "X-Original-To": [
            "incoming@patchwork.ozlabs.org",
            "gcc-patches@gcc.gnu.org"
        ],
        "Delivered-To": [
            "patchwork-incoming@legolas.ozlabs.org",
            "gcc-patches@gcc.gnu.org"
        ],
        "Authentication-Results": [
            "legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256\n header.s=20251104 header.b=nfx/L0zh;\n\tdkim-atps=neutral",
            "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org\n (client-ip=2620:52:6:3111::32; helo=vm01.sourceware.org;\n envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org;\n receiver=patchwork.ozlabs.org)",
            "sourceware.org;\n\tdkim=pass (2048-bit key,\n unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256\n header.s=20251104 header.b=nfx/L0zh",
            "sourceware.org;\n dmarc=pass (p=none dis=none) header.from=gmail.com",
            "sourceware.org; spf=pass smtp.mailfrom=gmail.com",
            "server2.sourceware.org;\n arc=none smtp.remote-ip=209.85.210.175"
        ],
        "Received": [
            "from vm01.sourceware.org (vm01.sourceware.org\n [IPv6:2620:52:6:3111::32])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fjz9N6xMSz1y1x\n\tfor <incoming@patchwork.ozlabs.org>; Sun, 29 Mar 2026 13:39:18 +1100 (AEDT)",
            "from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id E558F4BA9017\n\tfor <incoming@patchwork.ozlabs.org>; Sun, 29 Mar 2026 02:39:14 +0000 (GMT)",
            "from mail-pf1-f175.google.com (mail-pf1-f175.google.com\n [209.85.210.175])\n by sourceware.org (Postfix) with ESMTPS id 7755F4BA23EE\n for <gcc-patches@gcc.gnu.org>; Sun, 29 Mar 2026 02:38:15 +0000 (GMT)",
            "by mail-pf1-f175.google.com with SMTP id\n d2e1a72fcca58-82ae378fff8so2170612b3a.2\n for <gcc-patches@gcc.gnu.org>; Sat, 28 Mar 2026 19:38:15 -0700 (PDT)",
            "from [10.168.168.66] ([50.37.179.80])\n by smtp.gmail.com with ESMTPSA id\n 41be03b00d2f7-c76916cc65esm2629444a12.10.2026.03.28.19.38.12\n (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);\n Sat, 28 Mar 2026 19:38:13 -0700 (PDT)"
        ],
        "DKIM-Filter": [
            "OpenDKIM Filter v2.11.0 sourceware.org E558F4BA9017",
            "OpenDKIM Filter v2.11.0 sourceware.org 7755F4BA23EE"
        ],
        "DMARC-Filter": "OpenDMARC Filter v1.4.2 sourceware.org 7755F4BA23EE",
        "ARC-Filter": "OpenARC Filter v1.0.0 sourceware.org 7755F4BA23EE",
        "ARC-Seal": "i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1774751895; cv=none;\n b=PuZwn2RkIxdqSQVL2EXxgOclPgZPOyLpw+Irax4JmR2kOob9/zDFt/rnGd+0V3rCIfwWBSIDNcNBljgCoBrs5bD/Sx+bNge6ryg8e3Zm9uZebUSo2MUEmNRvTpRywOz+0LD/I0iJMwFrx6Gw9u5hpi/kKk8Rm9kCIRJuJjjkrDA=",
        "ARC-Message-Signature": "i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1774751895; c=relaxed/simple;\n bh=jk2O4obNrEdl6UwUKmZOPpVOgP2CckkfS8o0e6+O58Y=;\n h=DKIM-Signature:Message-ID:Date:MIME-Version:To:From:Subject;\n b=BOMxxRwAnoMXtJAuReKpRNnMnM6SsjFxAIJBPJtP4nLexJ8+dAqOO6JKutmCXXeyJ8DzlXPBlKud+l4KA6FmdSyK0RexIXjIQCaI+dthRXLoylTN631AQ12TxCX+iZ1K3hdyuAfDug8e8+Pjr+fwpHCnX5/jLbpWal+khU7CJIQ=",
        "ARC-Authentication-Results": "i=1; server2.sourceware.org",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=gmail.com; s=20251104; t=1774751894; x=1775356694; darn=gcc.gnu.org;\n h=autocrypt:subject:from:to:content-language:user-agent:mime-version\n :date:message-id:from:to:cc:subject:date:message-id:reply-to;\n bh=lWMA6vo+5OWK2DRD4qDwyx4u/jM6QR4zX/umnF6ULb4=;\n b=nfx/L0zhVXDAaqK7t+rQ/W28alzFuM34cNqpKRIaqBrbR22KMv31RwFXS169Vp6lhN\n IRK1E13cC11GimD1Cld/tC2VUd5ivtYetdDLTg6gCjkkkXsZgPdEyasvL3gC7/zPBloA\n PfhtYQhTLtkcb7oBDxHzQJmprTfqhk/dW93aWevVjTxYo6+b94oycmi1Zh1tuKSI8PJ7\n CKZJKz4cbZnbKfBsM+sRw48IasQX23dxDvjj91FuqM6kX5r1ljCoA0nAFHRM8izgLfiy\n 7jzWCFRmTqyFvxmlc9gRQBnLlieotBId2rgVrPVCF0bwUgs9SPqhKGoon9CAGKr/GGRa\n VlkQ==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1774751894; x=1775356694;\n h=autocrypt:subject:from:to:content-language:user-agent:mime-version\n :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date\n :message-id:reply-to;\n bh=lWMA6vo+5OWK2DRD4qDwyx4u/jM6QR4zX/umnF6ULb4=;\n b=UPiMLzsqfaoR2n+1Sg9GYtlNm5b94sw/TnvRRguexQUJ+6kH3OU8/u0Lq0Cwp13Nlz\n rFZcl4LEskmTw6JZC8GFmhZhoigfzqBurK9ajtK4lD112aA6/8sHVea4l6JI+obEUUUD\n oaATlolKB8gPCvsOVmqp78IgqQDyzRn9SWGS93P927hGiEnJS+F3HUTjkSKPkN+UvL9I\n EfBIR0voYMtwRDK56tvVMMpojxAhoJapl15EeFtMvBWs3yuomePVV1JZGAMUARDqLgix\n 5ChGSZBZrO4AZ1na1112PUgjaqc9hgfZu5hIA1gHY4KtVWGDaXwmJuGMLG0FiWpJJT9q\n MxGQ==",
        "X-Forwarded-Encrypted": "i=1;\n AJvYcCV9jBh7DpgQ3ZFvOhf2qhMB/69M6whWV1mE4wM0PAqZMlBufTVbGJm/+urJzmgib1H1BZYegb5xIQY5Ng==@gcc.gnu.org",
        "X-Gm-Message-State": "AOJu0Yyvpawpu4gkXi+HCz5IHwPWqHJzupM+Uv6+a4iZDyU8TpLI84Rk\n exBseOouc2kcgmO6hdq77EXRO1ilf0fbYInu6IUfiRU6EHlOq/c1Erpu",
        "X-Gm-Gg": "ATEYQzxZ10QB0ZHDVVo31T0l8iv3EHF7MYjfGnmiB6l5WiyIgndILgnZPAwKTirzV1k\n a2h9+fppesWrsOUkyi2o/5rINPwk/FD6SfEEIIMXzLc+S81bHFdm0nJ/fJ9K/pXTuJvYrX/h5fV\n mA0i0XyntpFgRTmWWtyqFVe55HA9kJDP7lPyq+wFZQDVVXw8wSjEJkZYefORy4fSDalnynKwfys\n ydJXheSKnf8DqIzBIGECAjAHil49BpQJmMw2T9gHu2pyEhzp44gvlYhp/T2c/qg9CLAFdymWVGK\n sW9GNJJzQ1ShWJzv9lAt/XT2+53K7So/zEmWxWFIYkuZ6eIGR9BJBI51ghmJpwr+cdSxPyqnTCh\n 5fxZLT5XrWsG3LhDaZxkAd1heO3iuY6QAdSpwhbkntwSunTMhDxibqXlEWkmCMjtqt17EaYxZxf\n cmY7kA79IQXY3Vo4WBNXMotVmqnqo=",
        "X-Received": "by 2002:a05:6a20:431d:b0:398:6fd3:769b with SMTP id\n adf61e73a8af0-39c879166ecmr8376838637.18.1774751894103;\n Sat, 28 Mar 2026 19:38:14 -0700 (PDT)",
        "Content-Type": "multipart/mixed; boundary=\"------------Nt6rG3U0RAM85qK0TiaurQpW\"",
        "Message-ID": "<50636c8a-9a19-48e1-835a-7024d6dfcc3e@gmail.com>",
        "Date": "Sat, 28 Mar 2026 19:38:12 -0700",
        "MIME-Version": "1.0",
        "User-Agent": "Mozilla Thunderbird",
        "Content-Language": "en-US",
        "To": "gfortran <fortran@gcc.gnu.org>, gcc-patches <gcc-patches@gcc.gnu.org>",
        "From": "Jerry D <jvdelisle2@gmail.com>",
        "Subject": "[PATCH, fortran] Fix Bug 124543 - INQUIRE: Sometimes returns\n incorrect values",
        "Autocrypt": "addr=jvdelisle2@gmail.com; keydata=\n xjMEY5TlkxYJKwYBBAHaRw8BAQdAyrkRDhmJhSTTlV/50gJLlvliU6/Lm5C9ViKV8T9y1GnN\n HkplcnJ5IEQgPGp2ZGVsaXNsZTJAZ21haWwuY29tPsKJBBMWCAAxFiEEOFR0TS0390uh8dRV\n uWXAJaWpwWoFAmOU5ZMCGwMECwkIBwUVCAkKCwUWAgMBAAAKCRC5ZcAlpanBalsJAP4wdCiH\n 2Of9oZv1QWgZ/AVdbWFM3Fv47/WZQHOXfoZ9HgD6AkXrKeJ+6usST7PEaDJjptaViT1fLiYY\n V/6XaOKSsgLOOARjlOWTEgorBgEEAZdVAQUBAQdAdA7PczYnl07vnOT9oP/wvvMDd4HP09Zl\n g3LzwXQJWT8DAQgHwngEGBYIACAWIQQ4VHRNLTf3S6Hx1FW5ZcAlpanBagUCY5TlkwIbDAAK\n CRC5ZcAlpanBasF/AQCa5WjlsVpLsEiggZyT18MOJNAdeRd7wkGDUrwedHrvawD/cE1H+/Ms\n L1ZwvQiLfGdx8crigQqWTQyos4kH8Wx82wc=",
        "X-BeenThere": "gcc-patches@gcc.gnu.org",
        "X-Mailman-Version": "2.1.30",
        "Precedence": "list",
        "List-Id": "Gcc-patches mailing list <gcc-patches.gcc.gnu.org>",
        "List-Unsubscribe": "<https://gcc.gnu.org/mailman/options/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe>",
        "List-Archive": "<https://gcc.gnu.org/pipermail/gcc-patches/>",
        "List-Post": "<mailto:gcc-patches@gcc.gnu.org>",
        "List-Help": "<mailto:gcc-patches-request@gcc.gnu.org?subject=help>",
        "List-Subscribe": "<https://gcc.gnu.org/mailman/listinfo/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe>",
        "Errors-To": "gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org"
    },
    "content": "Hello All,\n\nThe attached patch fixes numerous return values or missing checks.\n\nThere were at least two places where we segfaulted on checking a gfc_unit value \nwhen the unit did not exist.\n\nI have not implemented inquire (unit=lun, leading_zero=leading_zero) since this \nis rather new and I prefer to add it after this patch. It is one of those \nexamples of a new feature added that does not have a lot of value AFAICT. It \nwill require some front-end work.\n\nThe new test case is very busy. It is not too difficult to adjust if we miss \nanything there.\n\nRegression tested on X86_64.\n\nOK for mainline?\n\nRegards,\n\nJerry\n-----\n     fortran: Fix several issues with INQUIRE and unconnected units.\n\n             PR libfortran/124543\n\n     libgfortran/ChangeLog:\n\n             * io/inquire.c (inquire_via_unit): Fix return value for\n             NAMED. Add check for ACTION. Fix return values for\n             ENCODING, PENDING, READ, WRITE, READWRITE.\n             (inquire_via_filename): Add checks for ACTION, DELIM,\n             ASYNCHRONOUS, and PENDING. Fix return value for\n             ENCODING.\n             * io/unix.c (inquire_access): Change return value from no\n             to unknown.\n\n     gcc/testsuite/ChangeLog:\n\n             * gfortran.dg/pr124543.f90: New test.",
    "diff": "commit 21ef8e2c2110728a32a2da16be63abe817e00606\nAuthor: Jerry DeLisle <jvdelisle@gcc.gnu.org>\nDate:   Sat Mar 28 15:59:42 2026 -0700\n\n    fortran: Fix several issues with INQUIRE and unconnected units.\n    \n            PR libfortran/124543\n    \n    libgfortran/ChangeLog:\n    \n            * io/inquire.c (inquire_via_unit): Fix return value for\n            NAMED. Add check for ACTION. Fix return values for\n            ENCODING, PENDING, READ, WRITE, READWRITE.\n            (inquire_via_filename): Add checks for ACTION, DELIM,\n            ASYNCHRONOUS, and PENDING. Fix return value for\n            ENCODING.\n            * io/unix.c (inquire_access): Change return value from no\n            to unknown.\n    \n    gcc/testsuite/ChangeLog:\n    \n            * gfortran.dg/pr124543.f90: New test.\n\ndiff --git a/gcc/testsuite/gfortran.dg/pr124543.f90 b/gcc/testsuite/gfortran.dg/pr124543.f90\nnew file mode 100644\nindex 00000000000..8dc168de47c\n--- /dev/null\n+++ b/gcc/testsuite/gfortran.dg/pr124543.f90\n@@ -0,0 +1,391 @@\n+! { dg-do run )\n+\n+! PR124543, test case derived from that in the PR with several\n+! corrections\n+program inq_tests\n+  implicit none\n+\n+! Test various INQUIRE return values\n+! Most of these tests are based on Table C.1 in Section C.6.5 of F95.\n+! F2003, F2018 and F2023 can optionally be enabled.\n+\n+  character(16) :: access, action, blank, delim, direct, form, formatted\n+  character(16) :: name, pad, position, read, readwrite, sequential\n+  character(16) :: unformatted, write\n+\n+  logical :: exist, named, opened\n+  integer :: iostat, nextrec, number, recl\n+\n+  character(20) :: decimal, encoding, round, signc, stream\n+  integer :: pos\n+  character(16) :: async\n+  integer :: id\n+  logical :: pending\n+  character(16) :: leading_zero\n+\n+  integer, parameter :: lun = 42\n+  character(*), parameter :: lfn = 'fort.42'\n+\n+  integer :: fail_count = 0, pass_count = 0\n+\n+! Make sure there is no file with the name we will be using\n+  open (lun, file=lfn, status='old', iostat=iostat)\n+  if (iostat /= 0) then\n+    close (lun, status='delete')\n+  end if\n+\n+! File not connected yet\n+  call init_vars ()\n+  inquire (file=lfn, access=access, action=action, blank=blank, delim=delim, exist=exist,  &\n+      direct=direct, form=form, formatted=formatted, pad=pad, position=position,  &\n+      read=read, readwrite=readwrite, sequential=sequential, unformatted=unformatted,  &\n+      write=write, named=named, name=name, number=number, opened=opened, iostat=iostat)\n+  !print *, 'Unconnected INQUIRE by file'\n+  if  (iostat /= 0) stop 49\n+  if  (access /= 'UNDEFINED') stop 50\n+  if  (action /= 'UNDEFINED') stop 51\n+  if  (blank  /= 'UNDEFINED') stop 52\n+  if  (delim  /= 'UNDEFINED') stop 53\n+  if  (direct /= 'UNKNOWN') stop 54\n+  if  (exist) stop 55\n+  if  (form   /= 'UNDEFINED') stop 56\n+  if  (formatted /= 'UNKNOWN') stop 57\n+  if  (name   /= lfn) stop 58\n+  if  (.not. named) stop 59\n+  if  (number /= -1) stop 60\n+  if  (opened) stop 61\n+  if  (pad    /= 'UNDEFINED') stop 62\n+  if  (position /= 'UNDEFINED') stop 63\n+  if  (read   /= 'UNKNOWN') stop 64 ! The file does not exist.\n+  if  (readwrite /= 'UNKNOWN') stop 65\n+  if  (sequential /= 'UNKNOWN') stop 66\n+  if  (unformatted /= 'UNKNOWN') stop 67\n+  if  (write   /= 'UNKNOWN') stop 68\n+\n+  inquire (file=lfn, decimal=decimal, encoding=encoding, pos=pos,  &\n+      round=round, sign=signc, stream=stream)\n+  if  (decimal /= 'UNDEFINED') stop 72\n+  if  (encoding /= 'UNKNOWN') stop 73\n+  if  (round /= 'UNDEFINED') stop 74\n+  if  (signc /= 'UNDEFINED') stop 75\n+  if  (stream /= 'UNKNOWN') stop 76\n+  inquire (file=lfn, asynchronous=async)\n+  if  (async /= 'UNDEFINED') stop 78\n+  inquire (file=lfn, id=id, pending=pending, recl=recl)  ! SEGV at run-time w/gfortran\n+  if  (pending) print *, pending\n+  if  (recl /= -1) stop 81\n+!  inquire (file=lfn, leading_zero=leading_zero) stop\n+!  print *, 'leading_zero =', leading_zero, pf (leading_zero /= 'UNDEFINED')\n+\n+! Unit not connected yet\n+  call init_vars ()\n+  inquire (unit=lun, access=access, action=action, blank=blank, delim=delim,  &\n+      direct=direct, form=form, formatted=formatted, pad=pad, position=position,  &\n+      read=read, readwrite=readwrite, sequential=sequential, unformatted=unformatted,  &\n+      write=write, named=named, name=name, number=number, opened=opened, iostat=iostat)\n+  !print *\n+  !print *, 'Unconnected INQUIRE by unit'\n+  if  (iostat /= 0) stop 93\n+  if  (access /= 'UNDEFINED') stop 94\n+  if  (action /= 'UNDEFINED') stop 95\n+  if  (blank  /= 'UNDEFINED') stop 96\n+  if  (delim  /= 'UNDEFINED') stop 97\n+  if  (direct /= 'UNKNOWN') stop 98\n+  if  (exist) stop 99\n+  if  (form   /= 'UNDEFINED') stop 100\n+  if  (formatted /= 'UNKNOWN') stop 101\n+  if  (name   /= 'xxx') stop 102\n+  if  (named) stop 103\n+  if  (number /= -1) stop 104\n+  if  (opened) stop 105\n+  if  (pad    /= 'UNDEFINED') stop 106\n+  if  (position /= 'UNDEFINED') stop 107\n+  if  (read   /= 'UNKNOWN') stop 108\n+  if  (readwrite /= 'UNKNOWN') stop 109\n+  if  (sequential /= 'UNKNOWN') stop 110\n+  if  (unformatted /= 'UNKNOWN') stop 111\n+  if  (write   /= 'UNKNOWN') stop 112\n+\n+  inquire (unit=lun, decimal=decimal, encoding=encoding, pos=pos,  &\n+      round=round, sign=signc, stream=stream)\n+  if  (decimal /= 'UNDEFINED') stop 116\n+  if  (encoding /= 'UNKNOWN') stop 117\n+  if  (round /= 'UNDEFINED') stop 118\n+  if  (signc /= 'UNDEFINED') stop 119\n+  if  (stream /= 'UNKNOWN') stop 120\n+  inquire (unit=lun, asynchronous=async)\n+  if  (async /= 'UNDEFINED') stop 122\n+  inquire (unit=lun, id=id, pending=pending, recl=recl)  ! SEGV at run-time w/gfortran\n+  if  (pending) stop 124\n+  if  (recl   /= -1) stop 125\n+!  inquire (unit=lun, leading_zero=leading_zero)\n+!  print *, 'leading_zero =', leading_zero, pf (leading_zero /= 'UNDEFINED')\n+\n+! Open the file to connect it to the unit - sequential access\n+\n+  open (lun, file=lfn, status='new', access='sequential', form='formatted', recl=80)\n+  write (lun,*)'hello world!'\n+  rewind (lun)\n+\n+  call init_vars ()\n+  inquire (file=lfn, access=access, action=action, blank=blank, delim=delim, recl=recl,  &\n+      direct=direct, form=form, formatted=formatted, pad=pad, position=position, exist=exist, &\n+      read=read, readwrite=readwrite, sequential=sequential, unformatted=unformatted,  &\n+      write=write, named=named, name=name, number=number, opened=opened, iostat=iostat)\n+  !print *\n+  !print *, 'Connected INQUIRE by file (sequential)'\n+  if  (iostat /= 0) stop 142\n+  if  (access /= 'SEQUENTIAL') stop 143\n+  if  (action /= 'READWRITE') stop 144\n+  if  (blank  /= 'NULL') stop 145\n+  if  (delim  /= 'NONE') stop 146\n+  if  (direct /= 'NO') stop 147\n+  if  (.not. exist) stop 148\n+  if  (form   /= 'FORMATTED') stop 149\n+  if  (formatted /= 'YES') stop 150\n+  if  (name   /= lfn) stop 151\n+  if  (.not. named) stop 152\n+  if  (number /= 42) stop 153\n+  if  (.not. opened) stop 154\n+  if  (pad    /= 'YES') stop 155\n+  if  (position /= 'REWIND') stop 156\n+  if  (read   /= 'YES') stop 157\n+  if  (readwrite /= 'YES') stop 158\n+  if  (recl   /= 80) stop 159\n+  if  (sequential /= 'YES') stop 160\n+  if  (unformatted /= 'NO') stop 161\n+  if  (write   /= 'YES') stop 162\n+\n+  inquire (file=lfn, decimal=decimal, encoding=encoding, pos=pos,  &\n+      round=round, sign=signc, stream=stream)\n+  if  (decimal /= 'POINT') stop 166\n+  if  (encoding /= 'UNKNOWN') stop 167\n+  if  (round /= 'PROCESSOR_DEFINED') stop 168\n+  if  (signc /= 'PROCESSOR_DEFINED') stop 169\n+  if  (stream /= 'NO') stop 170\n+\n+! Unit is connected\n+  call init_vars ()\n+  inquire (unit=lun, access=access, action=action, blank=blank, recl=recl, delim=delim,  &\n+      direct=direct, form=form, formatted=formatted, pad=pad, position=position,  &\n+      read=read, readwrite=readwrite, sequential=sequential, unformatted=unformatted,  &\n+      write=write, named=named, name=name, number=number, opened=opened, iostat=iostat)\n+  !print *\n+  !print *, 'Connected INQUIRE by unit (sequential)'\n+  if  (iostat /= 0) stop 180\n+  if  (access /= 'SEQUENTIAL') stop 181\n+  if  (action /= 'READWRITE') stop 182\n+  if  (blank  /= 'NULL') stop 183\n+  if  (delim  /= 'NONE') stop 184\n+  if  (direct /= 'NO') stop 185\n+  if  (.not. exist) stop 186\n+  if  (form   /= 'FORMATTED') stop 187\n+  if  (formatted /= 'YES') stop 188\n+  if  (name   /= lfn) stop 189\n+  if  (.not. named) stop 190\n+  if  (number /= 42) stop 191\n+  if  (.not. opened) stop 192\n+  if  (pad    /= 'YES') stop 193\n+  if  (position /= 'REWIND') stop 194\n+  if  (read   /= 'YES') stop 195\n+  if  (readwrite /= 'YES') stop 196\n+  if  (recl   /= 80) stop 197\n+  if  (sequential /= 'YES') stop 198\n+  if  (unformatted /= 'NO') stop 199\n+  if  (write   /= 'YES') stop 200\n+\n+  inquire (unit=lun, decimal=decimal, encoding=encoding, pos=pos,  &\n+      round=round, sign=signc, stream=stream)\n+  if  (decimal /= 'POINT') stop 204\n+  if  (encoding /= 'UNKNOWN') stop 205\n+  if  (round /= 'PROCESSOR_DEFINED') stop 206\n+  if  (signc /= 'PROCESSOR_DEFINED') stop 207\n+  if  (stream /= 'NO') stop 208\n+\n+  close (lun, status='delete')\n+\n+! Open the file to connect it to the unit - sequential stream access\n+\n+  open (lun, file=lfn, status='new', access='stream', form='unformatted')\n+  write (lun) 'hello world!'\n+  rewind (lun)\n+\n+  call init_vars ()\n+  inquire (file=lfn, access=access, action=action, blank=blank, delim=delim,  &\n+      direct=direct, form=form, formatted=formatted, pad=pad, position=position,  &\n+      read=read, readwrite=readwrite, sequential=sequential, unformatted=unformatted,  &\n+      write=write, opened=opened, name=name, number=number, named=named, iostat=iostat)\n+  !print *\n+  !print *, 'Connected INQUIRE by file (stream, unformatted)'\n+  if  (iostat /= 0) stop 225\n+  if  (access /= 'STREAM') stop 226\n+  if  (action /= 'READWRITE') stop 227\n+  if  (blank  /= 'UNDEFINED') stop 228\n+  if  (delim  /= 'UNDEFINED') stop 229\n+  if  (direct /= 'NO') stop 230\n+  if  (.not. exist) stop 231\n+  if  (form   /= 'UNFORMATTED') stop 232\n+  if  (formatted /= 'NO') stop 233\n+  if  (name   /= lfn) stop 234\n+  if  (.not. named) stop 235\n+  if  (number /= 42) stop 236\n+  if  (.not. opened) stop 237\n+  if  (pad    /= 'UNDEFINED') stop 238\n+  if  (position /= 'REWIND') stop 239\n+  if  (read   /= 'YES') stop 240\n+  if  (readwrite /= 'YES') stop 241\n+  if  (sequential /= 'NO') stop 242\n+  if  (unformatted /= 'YES') stop 243\n+  if  (write   /= 'YES') stop 244\n+\n+  inquire (file=lfn, decimal=decimal, encoding=encoding, pos=pos,  &\n+      round=round, sign=signc, stream=stream, recl=recl)\n+  if  (decimal /= 'UNDEFINED') stop 248\n+  if  (encoding /= 'UNKNOWN') stop 249\n+  if  (round /= 'PROCESSOR_DEFINED') stop 250\n+  if  (signc /= 'PROCESSOR_DEFINED') stop 251\n+  if  (stream /= 'YES') stop 252\n+  if  (recl   /= -2) stop 253\n+\n+! Unit is connected\n+  call init_vars ()\n+  inquire (unit=lun, access=access, action=action, blank=blank, delim=delim, opened=opened,  &\n+      direct=direct, form=form, formatted=formatted, pad=pad, position=position,  &\n+      read=read, readwrite=readwrite, sequential=sequential, unformatted=unformatted,  &\n+      write=write, name=name, named=named, number=number, recl=recl, iostat=iostat)\n+  !print *\n+  !print *, 'Connected INQUIRE by unit (stream, unformatted)'\n+  if  (iostat /= 0) stop 263\n+  if  (access /= 'STREAM') stop 264\n+  if  (action /= 'READWRITE') stop 265\n+  if  (blank  /= 'UNDEFINED') stop 266\n+  if  (delim  /= 'UNDEFINED') stop 267\n+  if  (direct /= 'NO') stop 268\n+  if  (.not. exist) stop 269\n+  if  (form   /= 'UNFORMATTED') stop 270\n+  if  (formatted /= 'NO') stop 271\n+  if  (name   /= lfn) stop 272\n+  if  (.not. named) stop 273\n+  if  (number /= 42) stop 274\n+  if  (.not. opened) stop 275\n+  if  (pad    /= 'UNDEFINED') stop 276\n+  if  (position /= 'REWIND') stop 277\n+  if  (read   /= 'YES') stop 278\n+  if  (readwrite /= 'YES') stop 279\n+  if  (sequential /= 'NO') stop  280\n+  if  (unformatted /= 'YES') stop 281\n+  if  (write   /= 'YES') stop 282\n+\n+  inquire (unit=lun, decimal=decimal, encoding=encoding, pos=pos,  &\n+      round=round, sign=signc, stream=stream)\n+  if  (decimal /= 'UNDEFINED') stop 286\n+  if  (encoding /= 'UNKNOWN') stop 287\n+  if  (round /= 'PROCESSOR_DEFINED') stop 288\n+  if  (signc /= 'PROCESSOR_DEFINED') stop 289\n+  if  (stream /= 'YES') stop 290\n+  if  (recl   /= -2) stop 291\n+  close (lun, status='delete')\n+\n+! Open the file to connect it to the unit - direct access\n+\n+  open (lun, file=lfn, status='new', access='direct', recl=12, form='formatted')\n+  write (lun,rec=1, fmt='(a)') 'hello world!'\n+\n+  call init_vars ()\n+  inquire (file=lfn, access=access, action=action, blank=blank, delim=delim,  &\n+      direct=direct, form=form, formatted=formatted, nextrec=nextrec, pad=pad, opened=opened, &\n+      position=position, read=read, readwrite=readwrite, recl=recl, name=name, named=named,  &\n+      sequential=sequential, unformatted=unformatted, write=write, number=number, iostat=iostat)\n+  !print *\n+  !print *, 'Connected INQUIRE by file (direct, formatted)'\n+  if  (iostat /= 0) stop 306\n+  if  (access /= 'DIRECT') stop 307\n+  if  (action /= 'READWRITE') stop 308\n+  if  (blank  /= 'NULL') stop 309\n+  if  (delim  /= 'NONE') stop 310\n+  if  (direct /= 'YES') stop 311\n+  if  (.not. exist) stop 312\n+  if  (form   /= 'FORMATTED') stop 313\n+  if  (formatted /= 'YES') stop 314\n+  if  (name   /= lfn) stop 315\n+  if  (.not. named) stop 316\n+  if  (nextrec /= 2) stop 317\n+  if  (number /= 42) stop 318\n+  if  (.not. opened) stop 319\n+  if  (pad    /= 'YES') stop 320\n+  if  (position /= 'UNDEFINED') stop 31\n+  if  (read   /= 'YES') stop 322\n+  if  (readwrite /= 'YES') stop 323\n+  if  (recl   /= 12) stop 324\n+  if  (sequential /= 'NO') stop 325\n+  if  (unformatted /= 'NO') stop 326\n+  if  (write   /= 'YES') stop 327\n+\n+! Unit is connected\n+  call init_vars ()\n+  inquire (unit=lun, access=access, action=action, blank=blank, delim=delim,  &\n+      direct=direct, form=form, formatted=formatted, nextrec=nextrec, pad=pad, opened=opened,  &\n+      position=position, read=read, readwrite=readwrite, recl=recl, name=name, named=named, &\n+      sequential=sequential, unformatted=unformatted, write=write, number=number, iostat=iostat)\n+  !print *\n+  !print *, 'Connected INQUIRE by unit (direct, formatted)'\n+  if  (iostat /= 0) stop 337\n+  if  (access /= 'DIRECT') stop 338\n+  if  (action /= 'READWRITE') stop 339\n+  if  (blank  /= 'NULL') stop 340\n+  if  (delim  /= 'NONE') stop 341\n+  if  (direct /= 'YES') stop 342\n+  if  (.not. exist) stop 343\n+  if  (form   /= 'FORMATTED') stop 344\n+  if  (formatted /= 'YES') stop 345\n+  if  (name   /= lfn) stop 346\n+  if  (.not. named) stop 347\n+  if  (nextrec /= 2) stop 348\n+  if  (number /= 42) stop 349\n+  if  (.not. opened) stop 350\n+  if  (pad    /= 'YES') stop 351\n+  if  (position /= 'UNDEFINED') stop 352\n+  if  (read   /= 'YES') stop 353\n+  if  (readwrite /= 'YES') stop 354\n+  if  (recl   /= 12) stop 355\n+  if  (sequential /= 'NO') stop 356\n+  if  (unformatted /= 'NO') stop 357\n+  if  (write   /= 'YES') stop 358\n+\n+  close (lun, status=\"delete\")\n+  print *, \"all pass\"\n+contains\n+\n+  subroutine init_vars ()\n+\n+    access = 'xxx'\n+    action = 'xxx'\n+    blank = 'xxx'\n+    delim = 'xxx'\n+    direct = 'xxx'\n+    form = 'xxx'\n+    formatted = 'xxx'\n+    name = 'xxx'\n+    nextrec = -41\n+    number = -42\n+    pad = 'xxx'\n+    position = 'xxx'\n+    read = 'xxx'\n+    readwrite = 'xxx'\n+    recl = -43\n+    sequential = 'xxx'\n+    unformatted = 'xxx'\n+    write = 'xxx'\n+    decimal = 'xxx'\n+    encoding = 'xxx'\n+    round = 'xxx'\n+    pos = -44\n+    signc = 'xxx'\n+    stream = 'xxx'\n+    async = 'xxx'\n+    id = -45\n+    leading_zero = 'xxx'\n+\n+  end subroutine\n+\n+end program\ndiff --git a/libgfortran/io/inquire.c b/libgfortran/io/inquire.c\nindex 5c1bb78bd0d..f96210f1d57 100644\n--- a/libgfortran/io/inquire.c\n+++ b/libgfortran/io/inquire.c\n@@ -60,7 +60,11 @@ inquire_via_unit (st_parameter_inquire *iqp, gfc_unit *u)\n     *iqp->number = (u != NULL) ? u->unit_number : -1;\n \n   if ((cf & IOPARM_INQUIRE_HAS_NAMED) != 0)\n-    *iqp->named = (u != NULL && u->flags.status != STATUS_SCRATCH);\n+    {\n+      *iqp->named = 0;\n+      if (u != NULL && u->flags.status != STATUS_SCRATCH)\n+\t*iqp->named = 1;\n+    }\n \n   if ((cf & IOPARM_INQUIRE_HAS_NAME) != 0\n       && u != NULL && u->flags.status != STATUS_SCRATCH)\n@@ -119,6 +123,29 @@ inquire_via_unit (st_parameter_inquire *iqp, gfc_unit *u)\n       cf_strcpy (iqp->access, iqp->access_len, p);\n     }\n \n+  if ((cf & IOPARM_INQUIRE_HAS_ACTION) != 0)\n+    {\n+      if (u == NULL)\n+\tp = undefined;\n+      else\n+\tswitch (u->flags.action)\n+\t  {\n+\t  case ACTION_READ:\n+\t    p = \"READ\";\n+\t    break;\n+\t  case ACTION_WRITE:\n+\t    p = \"WRITE\";\n+\t    break;\n+\t  case ACTION_READWRITE:\n+\t    p = \"READWRITE\";\n+\t    break;\n+\t  default:\n+\t    internal_error (&iqp->common, \"inquire_via_filename(): Bad action\");\n+\t  }\n+\n+      cf_strcpy (iqp->action, iqp->action_len, p);\n+    }\n+\n   if ((cf & IOPARM_INQUIRE_HAS_SEQUENTIAL) != 0)\n     {\n       if (u == NULL)\n@@ -285,7 +312,7 @@ inquire_via_unit (st_parameter_inquire *iqp, gfc_unit *u)\n       if ((cf2 & IOPARM_INQUIRE_HAS_ENCODING) != 0)\n \t{\n \t  if (u == NULL || u->flags.form != FORM_FORMATTED)\n-\t    p = undefined;\n+\t    p = \"UNKNOWN\";\n           else\n \t    switch (u->flags.encoding)\n \t      {\n@@ -345,7 +372,9 @@ inquire_via_unit (st_parameter_inquire *iqp, gfc_unit *u)\n \n       if ((cf2 & IOPARM_INQUIRE_HAS_PENDING) != 0)\n \t{\n-\t  if (!ASYNC_IO || u->au == NULL)\n+\t  if (u == NULL)\n+\t    *iqp->pending = 0;\n+\t  else if (!ASYNC_IO || u->au == NULL)\n \t    *(iqp->pending) = 0;\n \t  else\n \t    {\n@@ -353,12 +382,12 @@ inquire_via_unit (st_parameter_inquire *iqp, gfc_unit *u)\n \t      if ((cf2 & IOPARM_INQUIRE_HAS_ID) != 0)\n \t\t{\n \t\t  int id;\n-\t\t  id = *(iqp->id);\n-\t\t  *(iqp->pending) = id > u->au->id.low;\n+\t\t  id = *iqp->id;\n+\t\t  *iqp->pending = id >= u->au->id.low;\n \t\t}\n \t      else\n \t\t{\n-\t\t  *(iqp->pending) = ! u->au->empty;\n+\t\t  *iqp->pending = !u->au->empty;\n \t\t}\n \t      UNLOCK (&(u->au->lock));\n \t    }\n@@ -567,19 +596,28 @@ inquire_via_unit (st_parameter_inquire *iqp, gfc_unit *u)\n \n   if ((cf & IOPARM_INQUIRE_HAS_READ) != 0)\n     {\n-      p = (!u || u->flags.action == ACTION_WRITE) ? no : yes;\n+      if (u == NULL)\n+\tp = \"UNKNOWN\";\n+      else\n+\tp = (!u || u->flags.action == ACTION_WRITE) ? no : yes;\n       cf_strcpy (iqp->read, iqp->read_len, p);\n     }\n \n   if ((cf & IOPARM_INQUIRE_HAS_WRITE) != 0)\n     {\n-      p = (!u || u->flags.action == ACTION_READ) ? no : yes;\n+      if (u == NULL)\n+\tp = \"UNKNOWN\";\n+      else\n+\tp = (!u || u->flags.action == ACTION_READ) ? no : yes;\n       cf_strcpy (iqp->write, iqp->write_len, p);\n     }\n \n   if ((cf & IOPARM_INQUIRE_HAS_READWRITE) != 0)\n     {\n-      p = (!u || u->flags.action != ACTION_READWRITE) ? no : yes;\n+      if (u == NULL)\n+\tp = \"UNKNOWN\";\n+      else\n+\tp = (!u || u->flags.action != ACTION_READWRITE) ? no : yes;\n       cf_strcpy (iqp->readwrite, iqp->readwrite_len, p);\n     }\n \n@@ -678,6 +716,12 @@ inquire_via_filename (st_parameter_inquire *iqp)\n   const char *p;\n   GFC_INTEGER_4 cf = iqp->common.flags;\n \n+  if ((cf & IOPARM_INQUIRE_HAS_ACTION) != 0)\n+    cf_strcpy (iqp->action, iqp->action_len, undefined);\n+\n+  if ((cf & IOPARM_INQUIRE_HAS_DELIM) != 0)\n+    cf_strcpy (iqp->delim, iqp->delim_len, undefined);\n+\n   if ((cf & IOPARM_INQUIRE_HAS_EXIST) != 0)\n     *iqp->exist = file_exists (iqp->file, iqp->file_len);\n \n@@ -722,7 +766,6 @@ inquire_via_filename (st_parameter_inquire *iqp)\n       p = \"UNKNOWN\";\n       cf_strcpy (iqp->unformatted, iqp->unformatted_len, p);\n     }\n-\n   if ((cf & IOPARM_INQUIRE_HAS_RECL_OUT) != 0)\n     /* F2018 (N2137) 12.10.2.26: If there is no connection, recl is\n        assigned the value -1.  */\n@@ -741,8 +784,20 @@ inquire_via_filename (st_parameter_inquire *iqp)\n     {\n       GFC_INTEGER_4 cf2 = iqp->flags2;\n \n+      if ((cf2 & IOPARM_INQUIRE_HAS_ASYNCHRONOUS) != 0)\n+\tcf_strcpy (iqp->asynchronous, iqp->asynchronous_len, undefined);\n+\n+      if ((cf2 & IOPARM_INQUIRE_HAS_PENDING) != 0)\n+\t*iqp->pending = 0;\n+\n       if ((cf2 & IOPARM_INQUIRE_HAS_ENCODING) != 0)\n-\tcf_strcpy (iqp->encoding, iqp->encoding_len, undefined);\n+\tcf_strcpy (iqp->encoding, iqp->encoding_len, \"UNKNOWN\");\n+\n+      if ((cf2 & IOPARM_INQUIRE_HAS_SIGN) != 0)\n+\tcf_strcpy (iqp->sign, iqp->sign_len, undefined);\n+\n+      if ((cf2 & IOPARM_INQUIRE_HAS_ROUND) != 0)\n+\tcf_strcpy (iqp->round, iqp->round_len, undefined);\n   \n       if ((cf2 & IOPARM_INQUIRE_HAS_DELIM) != 0)\n \tcf_strcpy (iqp->delim, iqp->delim_len, undefined);\n@@ -756,9 +811,6 @@ inquire_via_filename (st_parameter_inquire *iqp)\n       if ((cf2 & IOPARM_INQUIRE_HAS_PAD) != 0)\n \tcf_strcpy (iqp->pad, iqp->pad_len, undefined);\n   \n-      if ((cf2 & IOPARM_INQUIRE_HAS_ENCODING) != 0)\n-\tcf_strcpy (iqp->encoding, iqp->encoding_len, undefined);\n-\n       if ((cf2 & IOPARM_INQUIRE_HAS_SIZE) != 0)\n \t*iqp->size = file_size (iqp->file, iqp->file_len);\n \ndiff --git a/libgfortran/io/unix.c b/libgfortran/io/unix.c\nindex 2e8c790e475..2a115dc35a5 100644\n--- a/libgfortran/io/unix.c\n+++ b/libgfortran/io/unix.c\n@@ -2046,7 +2046,7 @@ inquire_access (const char *string, gfc_charlen_type len, int mode)\n   int res = access (path, mode);\n   free (path);\n   if (res == -1)\n-    return no;\n+    return unknown;\n \n   return yes;\n }\n",
    "prefixes": [
        "fortran"
    ]
}