@@ -704,29 +704,58 @@ void CheckHelper::CheckObjectEntity(
704
704
if (InPure () && !IsStmtFunction (DEREF (innermostSymbol_)) &&
705
705
!IsPointer (symbol) && !IsIntentIn (symbol) &&
706
706
!symbol.attrs ().test (Attr::VALUE)) {
707
- if (InFunction ()) { // C1583
708
- messages_.Say (
709
- " non-POINTER dummy argument of pure function must be INTENT(IN) or VALUE" _err_en_US);
710
- } else if (IsIntentOut (symbol)) {
707
+ const char *what{InFunction () ? " function" : " subroutine" };
708
+ bool ok{true };
709
+ if (IsIntentOut (symbol)) {
711
710
if (type && type->IsPolymorphic ()) { // C1588
712
711
messages_.Say (
713
- " An INTENT(OUT) dummy argument of a pure subroutine may not be polymorphic" _err_en_US);
712
+ " An INTENT(OUT) dummy argument of a pure %s may not be polymorphic" _err_en_US,
713
+ what);
714
+ ok = false ;
714
715
} else if (derived) {
715
716
if (FindUltimateComponent (*derived, [](const Symbol &x) {
716
717
const DeclTypeSpec *type{x.GetType ()};
717
718
return type && type->IsPolymorphic ();
718
719
})) { // C1588
719
720
messages_.Say (
720
- " An INTENT(OUT) dummy argument of a pure subroutine may not have a polymorphic ultimate component" _err_en_US);
721
+ " An INTENT(OUT) dummy argument of a pure %s may not have a polymorphic ultimate component" _err_en_US,
722
+ what);
723
+ ok = false ;
721
724
}
722
725
if (HasImpureFinal (symbol)) { // C1587
723
726
messages_.Say (
724
- " An INTENT(OUT) dummy argument of a pure subroutine may not have an impure FINAL subroutine" _err_en_US);
727
+ " An INTENT(OUT) dummy argument of a pure %s may not have an impure FINAL subroutine" _err_en_US,
728
+ what);
729
+ ok = false ;
725
730
}
726
731
}
727
732
} else if (!IsIntentInOut (symbol)) { // C1586
728
- messages_.Say (
729
- " non-POINTER dummy argument of pure subroutine must have INTENT() or VALUE attribute" _err_en_US);
733
+ if (context_.IsEnabled (common::LanguageFeature::RelaxedPureDummy)) {
734
+ if (context_.ShouldWarn (common::LanguageFeature::RelaxedPureDummy) &&
735
+ !InModuleFile () && !InElemental ()) {
736
+ messages_.Say (
737
+ " non-POINTER dummy argument of pure %s should have INTENT() or VALUE attribute" _warn_en_US,
738
+ what);
739
+ ok = false ;
740
+ }
741
+ } else {
742
+ messages_.Say (
743
+ " non-POINTER dummy argument of pure %s must have INTENT() or VALUE attribute" _warn_en_US,
744
+ what);
745
+ ok = false ;
746
+ }
747
+ }
748
+ if (ok && InFunction ()) {
749
+ if (context_.IsEnabled (common::LanguageFeature::RelaxedPureDummy)) {
750
+ if (context_.ShouldWarn (common::LanguageFeature::RelaxedPureDummy) &&
751
+ !InModuleFile () && !InElemental ()) {
752
+ messages_.Say (
753
+ " non-POINTER dummy argument of pure function should be INTENT(IN) or VALUE" _warn_en_US);
754
+ }
755
+ } else {
756
+ messages_.Say (
757
+ " non-POINTER dummy argument of pure function must be INTENT(IN) or VALUE" _err_en_US);
758
+ }
730
759
}
731
760
}
732
761
if (auto ignoreTKR{GetIgnoreTKR (symbol)}; !ignoreTKR.empty ()) {
@@ -798,9 +827,17 @@ void CheckHelper::CheckObjectEntity(
798
827
" A dummy argument of an ELEMENTAL procedure may not be a POINTER" _err_en_US);
799
828
}
800
829
if (!symbol.attrs ().HasAny (Attrs{Attr::VALUE, Attr::INTENT_IN,
801
- Attr::INTENT_INOUT, Attr::INTENT_OUT})) { // C15102
802
- messages_.Say (
803
- " A dummy argument of an ELEMENTAL procedure must have an INTENT() or VALUE attribute" _err_en_US);
830
+ Attr::INTENT_INOUT, Attr::INTENT_OUT})) { // F'2023 C15120
831
+ if (context_.IsEnabled (common::LanguageFeature::RelaxedPureDummy)) {
832
+ if (context_.ShouldWarn (common::LanguageFeature::RelaxedPureDummy) &&
833
+ !InModuleFile ()) {
834
+ messages_.Say (
835
+ " A dummy argument of an ELEMENTAL procedure should have an INTENT() or VALUE attribute" _warn_en_US);
836
+ }
837
+ } else {
838
+ messages_.Say (
839
+ " A dummy argument of an ELEMENTAL procedure must have an INTENT() or VALUE attribute" _err_en_US);
840
+ }
804
841
}
805
842
} else if (IsFunctionResult (symbol)) { // C15101
806
843
if (details.shape ().Rank () > 0 ) {
0 commit comments