@@ -289,6 +289,14 @@ void CheckHelper::Check(const Symbol &symbol) {
289
289
messages_.Say (
290
290
" An entity may not have the ASYNCHRONOUS attribute unless it is a variable" _err_en_US);
291
291
}
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
+ }
292
300
293
301
if (isDone) {
294
302
return ; // following checks do not apply
@@ -411,9 +419,6 @@ void CheckHelper::Check(const Symbol &symbol) {
411
419
// The non-dummy case is a hard error that's caught elsewhere.
412
420
}
413
421
}
414
- if (symbol.attrs ().test (Attr::VALUE)) {
415
- CheckValue (symbol, derived);
416
- }
417
422
if (IsDummy (symbol)) {
418
423
if (IsNamedConstant (symbol)) {
419
424
messages_.Say (
@@ -527,13 +532,10 @@ void CheckHelper::CheckBindCFunctionResult(const Symbol &symbol) { // C1553
527
532
528
533
void CheckHelper::CheckValue (
529
534
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
- }
534
535
if (IsProcedure (symbol)) {
535
536
messages_.Say (
536
537
" VALUE attribute may apply only to a dummy data object" _err_en_US);
538
+ return ; // don't pile on
537
539
}
538
540
if (IsAssumedSizeArray (symbol)) {
539
541
messages_.Say (
@@ -786,14 +788,6 @@ void CheckHelper::CheckObjectEntity(
786
788
}
787
789
}
788
790
}
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
797
791
} else if (!details.ignoreTKR ().empty ()) {
798
792
messages_.Say (
799
793
" !DIR$ IGNORE_TKR directive may apply only to a dummy data argument" _err_en_US);
@@ -1214,9 +1208,8 @@ void CheckHelper::CheckProcEntity(
1214
1208
const Symbol *interface{details.procInterface ()};
1215
1209
if (details.isDummy ()) {
1216
1210
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})) {
1220
1213
messages_.Say (" A dummy procedure without the POINTER attribute"
1221
1214
" may not have an INTENT attribute" _err_en_US);
1222
1215
}
@@ -1240,14 +1233,6 @@ void CheckHelper::CheckProcEntity(
1240
1233
messages_.Say (" A dummy procedure may not be ELEMENTAL" _err_en_US);
1241
1234
}
1242
1235
}
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
1251
1236
} else if (IsPointer (symbol)) {
1252
1237
CheckPointerInitialization (symbol);
1253
1238
if (interface) {
0 commit comments