[flang] Support CONVERT= and DISPOSE= on INQUIRE
authorpeter klausler <pklausler@nvidia.com>
Fri, 22 Mar 2019 22:08:16 +0000 (15:08 -0700)
committerpeter klausler <pklausler@nvidia.com>
Mon, 1 Apr 2019 17:14:19 +0000 (10:14 -0700)
Original-commit: flang-compiler/f18@fbedd32376eb71d289177cfe127d1d4835a51a61
Reviewed-on: https://github.com/flang-compiler/f18/pull/352
Tree-same-pre-rewrite: false

flang/documentation/Extensions.md
flang/documentation/f2018-grammar.txt
flang/lib/evaluate/integer.h
flang/lib/parser/features.h
flang/lib/parser/format-specification.h
flang/lib/parser/grammar.h
flang/lib/parser/parse-tree.h
flang/lib/parser/stmt-parser.h
flang/lib/parser/token-parsers.h
flang/test/evaluate/integer.cc

index d4190db..4771100 100644 (file)
@@ -45,10 +45,10 @@ Extensions, deletions, and legacy features supported by default
 * `+` and `-` before all primary expressions, e.g. `x*-y`
 * `.NOT. .NOT.` accepted
 * `NAME=` as synonym for `FILE=`
-* `DISPOSE=`
 * Data edit descriptors without width or other details
 * `D` lines in fixed form as comments or debug code
-* `CONVERT=` on the OPEN statement
+* `CONVERT=` on the OPEN and INQUIRE statements
+* `DISPOSE=` on the OPEN and INQUIRE statements
 * Leading semicolons are ignored before any statement that
   could have a label
 * The character `&` in column 1 in fixed form source is a variant form
index 727a744..ab03a81 100644 (file)
@@ -570,6 +570,8 @@ R1205 connect-spec ->
         POSITION = scalar-default-char-expr | RECL = scalar-int-expr |
         ROUND = scalar-default-char-expr | SIGN = scalar-default-char-expr |
         STATUS = scalar-default-char-expr
+        @ | CONVERT = scalar-default-char-expr
+          | DISPOSE = scalar-default-char-expr
 R1206 file-name-expr -> scalar-default-char-expr
 R1207 iomsg-variable -> scalar-default-char-variable
 R1208 close-stmt -> CLOSE ( close-spec-list )
@@ -648,6 +650,8 @@ R1231 inquire-spec ->
         STREAM = scalar-default-char-variable |
         STATUS = scalar-default-char-variable |
         WRITE = scalar-default-char-variable
+        @ | CONVERT = scalar-default-char-expr
+          | DISPOSE = scalar-default-char-expr
 
 R1301 format-stmt -> FORMAT format-specification
 R1302 format-specification ->
index b0b9189..b3b06cd 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (c) 2018, NVIDIA CORPORATION.  All rights reserved.
+// Copyright (c) 2018-2019, NVIDIA CORPORATION.  All rights reserved.
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
index 6ba3498..87c2b09 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (c) 2018, NVIDIA CORPORATION.  All rights reserved.
+// Copyright (c) 2018-2019, NVIDIA CORPORATION.  All rights reserved.
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
index 8d620d4..727bbad 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (c) 2018, NVIDIA CORPORATION.  All rights reserved.
+// Copyright (c) 2018-2019, NVIDIA CORPORATION.  All rights reserved.
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
index ee14827..66ce639 100644 (file)
@@ -2434,6 +2434,8 @@ constexpr auto fileNameExpr{scalarDefaultCharExpr};
 //         POSITION = scalar-default-char-expr | RECL = scalar-int-expr |
 //         ROUND = scalar-default-char-expr | SIGN = scalar-default-char-expr |
 //         STATUS = scalar-default-char-expr
+//         @ | CONVERT = scalar-default-char-variable
+//         @ | DISPOSE = scalar-default-char-variable
 constexpr auto statusExpr{construct<StatusExpr>(scalarDefaultCharExpr)};
 constexpr auto errLabel{construct<ErrLabel>(label)};
 
@@ -2734,6 +2736,8 @@ TYPE_CONTEXT_PARSER("FLUSH statement"_en_US,
 //         STREAM = scalar-default-char-variable |
 //         STATUS = scalar-default-char-variable |
 //         WRITE = scalar-default-char-variable
+//         @ | CONVERT = scalar-default-char-variable
+//           | DISPOSE = scalar-default-char-variable
 TYPE_PARSER(first(construct<InquireSpec>(maybe("UNIT ="_tok) >> fileUnitNumber),
     construct<InquireSpec>("FILE =" >> fileNameExpr),
     construct<InquireSpec>(
@@ -2849,7 +2853,15 @@ TYPE_PARSER(first(construct<InquireSpec>(maybe("UNIT ="_tok) >> fileUnitNumber),
                                scalarDefaultCharVariable)),
     construct<InquireSpec>("WRITE =" >>
         construct<InquireSpec::CharVar>(pure(InquireSpec::CharVar::Kind::Write),
-            scalarDefaultCharVariable))))
+            scalarDefaultCharVariable)),
+    extension<LanguageFeature::Convert>(construct<InquireSpec>(
+        "CONVERT =" >> construct<InquireSpec::CharVar>(
+                           pure(InquireSpec::CharVar::Kind::Convert),
+                           scalarDefaultCharVariable))),
+    extension<LanguageFeature::Dispose>(construct<InquireSpec>(
+        "DISPOSE =" >> construct<InquireSpec::CharVar>(
+                           pure(InquireSpec::CharVar::Kind::Dispose),
+                           scalarDefaultCharVariable)))))
 
 // R1230 inquire-stmt ->
 //         INQUIRE ( inquire-spec-list ) |
index 003126b..5e5925a 100644 (file)
@@ -2508,6 +2508,8 @@ using FileNameExpr = ScalarDefaultCharExpr;
 //         POSITION = scalar-default-char-expr | RECL = scalar-int-expr |
 //         ROUND = scalar-default-char-expr | SIGN = scalar-default-char-expr |
 //         STATUS = scalar-default-char-expr
+//         @ | CONVERT = scalar-default-char-variable
+//           | DISPOSE = scalar-default-char-variable
 WRAPPER_CLASS(StatusExpr, ScalarDefaultCharExpr);
 WRAPPER_CLASS(ErrLabel, Label);
 
@@ -2721,12 +2723,15 @@ WRAPPER_CLASS(FlushStmt, std::list<PositionOrFlushSpec>);
 //         STATUS = scalar-default-char-variable |
 //         UNFORMATTED = scalar-default-char-variable |
 //         WRITE = scalar-default-char-variable
+//         @ | CONVERT = scalar-default-char-variable
+//           | DISPOSE = scalar-default-char-variable
 struct InquireSpec {
   UNION_CLASS_BOILERPLATE(InquireSpec);
   struct CharVar {
     ENUM_CLASS(Kind, Access, Action, Asynchronous, Blank, Decimal, Delim,
         Direct, Encoding, Form, Formatted, Iomsg, Name, Pad, Position, Read,
-        Readwrite, Round, Sequential, Sign, Stream, Status, Unformatted, Write)
+        Readwrite, Round, Sequential, Sign, Stream, Status, Unformatted, Write,
+        /* extensions: */ Convert, Dispose)
     TUPLE_CLASS_BOILERPLATE(CharVar);
     std::tuple<Kind, ScalarDefaultCharVariable> t;
   };
index 15c7821..fb7d6d6 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (c) 2018, NVIDIA CORPORATION.  All rights reserved.
+// Copyright (c) 2018-2019, NVIDIA CORPORATION.  All rights reserved.
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
index 9a426ad..51e1014 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (c) 2018, NVIDIA CORPORATION.  All rights reserved.
+// Copyright (c) 2018-2019, NVIDIA CORPORATION.  All rights reserved.
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
index 0c827f1..1e82c4e 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (c) 2018, NVIDIA CORPORATION.  All rights reserved.
+// Copyright (c) 2018-2019, NVIDIA CORPORATION.  All rights reserved.
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.