flang icon indicating copy to clipboard operation
flang copied to clipboard

Add more checkings for derived types in COMMON statements

Open qiaozhang-hnc opened this issue 3 years ago • 2 comments

This patch fixes two problems:

  1. When two or more COMMON blocks with the same name have objects with default initialization, flang will execute each initialization more than once. The first pass will carry out normally, whereas the others will be rejected in the write_comm function, leaving the DSRT pointer un-nullified, ultimately causing a segmentation fault.
  2. If a common-block-object is of a derived type, the type shall have the BIND attribute or the SEQUENCE attribute and it shall have no default initialization. A common-block-object shall not be a derived-type object with an ultimate component that is allocatable. flang fails to enforce the above restrictions on derived types.

This patch fixes the 2 problems above by setting DSRT to NULL at the right time and capturing/reporting the aforementioned syntactical error.

qiaozhang-hnc avatar Jun 16 '21 08:06 qiaozhang-hnc

@qiaozhang-hnc Could you rebase this branch please?

bryanpkc avatar Mar 09 '22 14:03 bryanpkc

@qiaozhang-hnc Could you rebase this branch please?

Rebased.

qiaozhang-hnc avatar Mar 22 '22 08:03 qiaozhang-hnc