@@ -53,8 +53,7 @@ class CheckHelper {
53
53
evaluate::CheckSpecificationExpr (x, DEREF (scope_), foldingContext_);
54
54
}
55
55
void CheckValue (const Symbol &, const DerivedTypeSpec *);
56
- void CheckVolatile (
57
- const Symbol &, bool isAssociated, const DerivedTypeSpec *);
56
+ void CheckVolatile (const Symbol &, const DerivedTypeSpec *);
58
57
void CheckPointer (const Symbol &);
59
58
void CheckPassArg (
60
59
const Symbol &proc, const Symbol *interface, const WithPassArg &);
@@ -172,22 +171,18 @@ void CheckHelper::Check(const Symbol &symbol) {
172
171
context_.set_location (symbol.name ());
173
172
const DeclTypeSpec *type{symbol.GetType ()};
174
173
const DerivedTypeSpec *derived{type ? type->AsDerived () : nullptr };
175
- bool isAssociated{symbol.has <UseDetails>() || symbol.has <HostAssocDetails>()};
176
- if (symbol.attrs ().test (Attr::VOLATILE)) {
177
- CheckVolatile (symbol, isAssociated, derived);
178
- }
179
- if (isAssociated) {
180
- if (const auto *details{symbol.detailsIf <HostAssocDetails>()}) {
181
- CheckHostAssoc (symbol, *details);
182
- }
183
- return ; // no other checks on associated symbols
184
- }
185
- if (IsPointer (symbol)) {
186
- CheckPointer (symbol);
187
- }
174
+ bool isDone{false };
188
175
std::visit (
189
176
common::visitors{
190
- [&](const ProcBindingDetails &x) { CheckProcBinding (symbol, x); },
177
+ [&](const UseDetails &x) { isDone = true ; },
178
+ [&](const HostAssocDetails &x) {
179
+ CheckHostAssoc (symbol, x);
180
+ isDone = true ;
181
+ },
182
+ [&](const ProcBindingDetails &x) {
183
+ CheckProcBinding (symbol, x);
184
+ isDone = true ;
185
+ },
191
186
[&](const ObjectEntityDetails &x) { CheckObjectEntity (symbol, x); },
192
187
[&](const ProcEntityDetails &x) { CheckProcEntity (symbol, x); },
193
188
[&](const SubprogramDetails &x) { CheckSubprogram (symbol, x); },
@@ -196,6 +191,15 @@ void CheckHelper::Check(const Symbol &symbol) {
196
191
[](const auto &) {},
197
192
},
198
193
symbol.details ());
194
+ if (symbol.attrs ().test (Attr::VOLATILE)) {
195
+ CheckVolatile (symbol, derived);
196
+ }
197
+ if (isDone) {
198
+ return ; // following checks do not apply
199
+ }
200
+ if (IsPointer (symbol)) {
201
+ CheckPointer (symbol);
202
+ }
199
203
if (InPure ()) {
200
204
if (IsSaved (symbol)) {
201
205
messages_.Say (
@@ -1279,7 +1283,7 @@ const Procedure *CheckHelper::Characterize(const Symbol &symbol) {
1279
1283
return common::GetPtrFromOptional (it->second );
1280
1284
}
1281
1285
1282
- void CheckHelper::CheckVolatile (const Symbol &symbol, bool isAssociated,
1286
+ void CheckHelper::CheckVolatile (const Symbol &symbol,
1283
1287
const DerivedTypeSpec *derived) { // C866 - C868
1284
1288
if (IsIntentIn (symbol)) {
1285
1289
messages_.Say (
@@ -1288,7 +1292,7 @@ void CheckHelper::CheckVolatile(const Symbol &symbol, bool isAssociated,
1288
1292
if (IsProcedure (symbol)) {
1289
1293
messages_.Say (" VOLATILE attribute may apply only to a variable" _err_en_US);
1290
1294
}
1291
- if (isAssociated ) {
1295
+ if (symbol. has <UseDetails>() || symbol. has <HostAssocDetails>() ) {
1292
1296
const Symbol &ultimate{symbol.GetUltimate ()};
1293
1297
if (IsCoarray (ultimate)) {
1294
1298
messages_.Say (
0 commit comments