@@ -289,6 +289,14 @@ void CheckHelper::Check(const Symbol &symbol) {
289289 messages_.Say (
290290 " An entity may not have the ASYNCHRONOUS attribute unless it is a variable" _err_en_US);
291291 }
292+ if (symbol.attrs ().HasAny ({Attr::INTENT_IN, Attr::INTENT_INOUT,
293+ Attr::INTENT_OUT, Attr::OPTIONAL, Attr::VALUE}) &&
294+ !IsDummy (symbol)) {
295+ messages_.Say (
296+ " Only a dummy argument may have an INTENT, VALUE, or OPTIONAL attribute" _err_en_US);
297+ } else if (symbol.attrs ().test (Attr::VALUE)) {
298+ CheckValue (symbol, derived);
299+ }
292300
293301 if (isDone) {
294302 return ; // following checks do not apply
@@ -411,9 +419,6 @@ void CheckHelper::Check(const Symbol &symbol) {
411419 // The non-dummy case is a hard error that's caught elsewhere.
412420 }
413421 }
414- if (symbol.attrs ().test (Attr::VALUE)) {
415- CheckValue (symbol, derived);
416- }
417422 if (IsDummy (symbol)) {
418423 if (IsNamedConstant (symbol)) {
419424 messages_.Say (
@@ -527,13 +532,10 @@ void CheckHelper::CheckBindCFunctionResult(const Symbol &symbol) { // C1553
527532
528533void CheckHelper::CheckValue (
529534 const Symbol &symbol, const DerivedTypeSpec *derived) { // C863 - C865
530- if (!IsDummy (symbol)) {
531- messages_.Say (
532- " VALUE attribute may apply only to a dummy argument" _err_en_US);
533- }
534535 if (IsProcedure (symbol)) {
535536 messages_.Say (
536537 " VALUE attribute may apply only to a dummy data object" _err_en_US);
538+ return ; // don't pile on
537539 }
538540 if (IsAssumedSizeArray (symbol)) {
539541 messages_.Say (
@@ -786,14 +788,6 @@ void CheckHelper::CheckObjectEntity(
786788 }
787789 }
788790 }
789- } else if (symbol.attrs ().test (Attr::INTENT_IN) ||
790- symbol.attrs ().test (Attr::INTENT_OUT) ||
791- symbol.attrs ().test (Attr::INTENT_INOUT)) {
792- messages_.Say (
793- " INTENT attributes may apply only to a dummy argument" _err_en_US); // C843
794- } else if (IsOptional (symbol)) {
795- messages_.Say (
796- " OPTIONAL attribute may apply only to a dummy argument" _err_en_US); // C849
797791 } else if (!details.ignoreTKR ().empty ()) {
798792 messages_.Say (
799793 " !DIR$ IGNORE_TKR directive may apply only to a dummy data argument" _err_en_US);
@@ -1214,9 +1208,8 @@ void CheckHelper::CheckProcEntity(
12141208 const Symbol *interface{details.procInterface ()};
12151209 if (details.isDummy ()) {
12161210 if (!symbol.attrs ().test (Attr::POINTER) && // C843
1217- (symbol.attrs ().test (Attr::INTENT_IN) ||
1218- symbol.attrs ().test (Attr::INTENT_OUT) ||
1219- symbol.attrs ().test (Attr::INTENT_INOUT))) {
1211+ symbol.attrs ().HasAny (
1212+ {Attr::INTENT_IN, Attr::INTENT_OUT, Attr::INTENT_INOUT})) {
12201213 messages_.Say (" A dummy procedure without the POINTER attribute"
12211214 " may not have an INTENT attribute" _err_en_US);
12221215 }
@@ -1240,14 +1233,6 @@ void CheckHelper::CheckProcEntity(
12401233 messages_.Say (" A dummy procedure may not be ELEMENTAL" _err_en_US);
12411234 }
12421235 }
1243- } else if (symbol.attrs ().test (Attr::INTENT_IN) ||
1244- symbol.attrs ().test (Attr::INTENT_OUT) ||
1245- symbol.attrs ().test (Attr::INTENT_INOUT)) {
1246- messages_.Say (" INTENT attributes may apply only to a dummy "
1247- " argument" _err_en_US); // C843
1248- } else if (IsOptional (symbol)) {
1249- messages_.Say (" OPTIONAL attribute may apply only to a dummy "
1250- " argument" _err_en_US); // C849
12511236 } else if (IsPointer (symbol)) {
12521237 CheckPointerInitialization (symbol);
12531238 if (interface) {
0 commit comments