[flang] Simplify CommonStmt in parse tree
The grammar requires parsing the first common block in a common stmt
differently from the others: the '//' is optional for the blank common.
But once it's parsed, it is easier to work with if each is represented
as a `parser::CommonStmt::Block`. This is achieved by using the same
constructor for `CommonStmt` but then including the first block in
the list of blocks.
Original-commit: flang-compiler/f18@dd46afd6b5607ec61ea9b2e97efa16deda31441b
Reviewed-on: https://github.com/flang-compiler/f18/pull/284
diff --git a/flang/lib/parser/unparse.cc b/flang/lib/parser/unparse.cc
index 2ffd9a5..891f5c3 100644
--- a/flang/lib/parser/unparse.cc
+++ b/flang/lib/parser/unparse.cc
@@ -703,9 +703,7 @@
}
void Unparse(const CommonStmt &x) { // R873
Word("COMMON ");
- Walk("/", std::get<std::optional<Name>>(x.t), "/");
- Walk(std::get<std::list<CommonBlockObject>>(x.t), ", ");
- Walk(", ", std::get<std::list<CommonStmt::Block>>(x.t), ", ");
+ Walk(x.blocks);
}
void Unparse(const CommonBlockObject &x) { // R874
Walk(std::get<Name>(x.t));