[flang] Fix SELECT TYPE lowering when CLASS DEFAULT is not the last type guard
authorValentin Clement <clementval@gmail.com>
Thu, 19 Jan 2023 16:32:02 +0000 (17:32 +0100)
committerValentin Clement <clementval@gmail.com>
Thu, 19 Jan 2023 16:32:31 +0000 (17:32 +0100)
commita459a2485b54fbd9e1f8a48061e79cdcd12b12a5
treea9789526b2bfb5543966162979a68ee2b93c2fc2
parentc85cecf36bf8b64b541becb0ec3ec11379d062e7
[flang] Fix SELECT TYPE lowering when CLASS DEFAULT is not the last type guard

CLASS DEFAULT needs to be the last attribute when fir.select_type op is created.
It needs to be at its actual position in the Fortran code when the TypeGuardStmt
are processed. The current lowering was crashing when CLASS DEFAULT was not at
the last position.
This patch fixes the issue by tracking the actual position of the CLASS DEFAULT
type guard and set it at the correct position after the fir.select_type op
is created.

Reviewed By: jeanPerier, PeteSteinfeld

Differential Revision: https://reviews.llvm.org/D142091
flang/lib/Lower/Bridge.cpp
flang/test/Lower/select-type.f90