[flang] Simplify grammar for STOP/ERROR STOP.
authorpeter klausler <pklausler@nvidia.com>
Tue, 19 Mar 2019 18:44:35 +0000 (11:44 -0700)
committerpeter klausler <pklausler@nvidia.com>
Tue, 19 Mar 2019 18:44:35 +0000 (11:44 -0700)
Original-commit: flang-compiler/f18@eddaea25a2f9be240edad9127aa412fbd2923e4a
Reviewed-on: https://github.com/flang-compiler/f18/pull/342
Tree-same-pre-rewrite: false

flang/lib/parser/grammar.h
flang/lib/parser/parse-tree.h

index cb132db..1f04f42 100644 (file)
@@ -2324,8 +2324,9 @@ TYPE_CONTEXT_PARSER("STOP statement"_en_US,
         maybe(Parser<StopCode>{}), maybe(", QUIET =" >> scalarLogicalExpr)))
 
 // R1162 stop-code -> scalar-default-char-expr | scalar-int-expr
-TYPE_PARSER(construct<StopCode>(scalarDefaultCharExpr) ||
-    construct<StopCode>(scalarIntExpr))
+// The two alternatives for stop-code can't be distinguished at
+// parse time.
+TYPE_PARSER(construct<StopCode>(expr))
 
 // R1164 sync-all-stmt -> SYNC ALL [( [sync-stat-list] )]
 TYPE_CONTEXT_PARSER("SYNC ALL statement"_en_US,
index 99a3fa5..1439847 100644 (file)
@@ -2391,10 +2391,10 @@ struct ComputedGotoStmt {
 };
 
 // R1162 stop-code -> scalar-default-char-expr | scalar-int-expr
-struct StopCode {
-  UNION_CLASS_BOILERPLATE(StopCode);
-  std::variant<ScalarDefaultCharExpr, ScalarIntExpr> u;
-};
+// We can't distinguish character expressions from integer
+// expressions until semantics, so we just parse an expr and
+// check its type later.
+WRAPPER_CLASS(StopCode, Expr);
 
 // R1160 stop-stmt -> STOP [stop-code] [, QUIET = scalar-logical-expr]
 // R1161 error-stop-stmt ->