[flang-dev] Regarding main program structure

Timothy Keith via flang-dev flang-dev at lists.llvm.org
Fri Oct 25 07:47:31 PDT 2019


SpecificationPart is made up of lists of other nodes. When the specification-part of a program is absent, it is represented by a SpecificationPart containing only empty lists. So there is no need to make it optional. The same applies to ExecutionPart.

Tim

From: flang-dev <flang-dev-bounces at lists.llvm.org> on behalf of Rajesh K Singh via flang-dev <flang-dev at lists.llvm.org>
Reply-To: Rajesh K Singh <rajeshsingh.h606 at gmail.com>
Date: Friday, October 25, 2019 at 2:05 AM
To: "flang-dev at lists.llvm.org" <flang-dev at lists.llvm.org>
Subject: [flang-dev] Regarding main program structure

Hello,

According to specification R1401, a Fortran main program *must* have an “end statement” whereas other parts are optional.
// R1401 main-program ->
//         [program-stmt] [specification-part] [execution-part]
//         [internal-subprogram-part] end-program-stmt

Thus, the below case.f90 is a legitimate fortran program:
[user at localhost ~/F18]$ cat -n case.f90
     1  end  !only end-program-stmt is specified.
[user at localhost ~/F18]$

The implementation of MainProgram structure (“lib/parser/parse-tree.h”) shows that only “ProgramStmt” and “InternalSubprogramPart” are optional.
struct MainProgram {
  TUPLE_CLASS_BOILERPLATE(MainProgram);
  std::tuple<std::optional<Statement<ProgramStmt>>, SpecificationPart,
      ExecutionPart, std::optional<InternalSubprogramPart>,
      Statement<EndProgramStmt>>
      t;
};

Why “SpecificationPart” and “ExecutionPart” are not implemented as optional (std::optional), while these are optional similar to “ProgramStmt” and “InternalSubprogramPart”?

Thanks in anticipation.

-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain
confidential information.  Any unauthorized review, use, disclosure or distribution
is prohibited.  If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/flang-dev/attachments/20191025/3d7358b3/attachment.html>


More information about the flang-dev mailing list