llvm-project/flang/lib/Semantics/check-namelist.h
Tom Eccles 3717048496
[flang][Semantics][OpenMP] don't reduce variables in namelist (#110671)
This is allowed by the OpenMP and F23 standards. But variables in a
namelist are not allowed in OpenMP privatisation. I suspect this was an
oversight.

If we allow this we run into problems masking the original symbol with
the symbol for the reduction variable when the variable is accessed via
a namelist initialised as a global variable. See #101907. One solution
for this would be to force the namelist to always be initilized inside
of the block in which it is used (therefore using the correct mapping
for the reduction variable), but this could make some production
applications slow.

I tentatively think it is probably better to disallow a (perhaps
mistaken) edge case of the standards with (I think) little practical
use, than to make real applications slow in order to make this work. If
reviewers would rather keep to the letter of the standard, see #109303
which implements the alternative solution. I'm open to either path
forward.

Fixes #101907
2024-10-02 10:21:14 +01:00

27 lines
915 B
C++

//===-------lib/Semantics/check-namelist.h --------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef FORTRAN_SEMANTICS_CHECK_NAMELIST_H_
#define FORTRAN_SEMANTICS_CHECK_NAMELIST_H_
#include "flang/Parser/parse-tree.h"
#include "flang/Semantics/semantics.h"
namespace Fortran::semantics {
class NamelistChecker : public virtual BaseChecker {
public:
NamelistChecker(SemanticsContext &context) : context_{context} {}
void Leave(const parser::NamelistStmt &);
void Leave(const parser::LocalitySpec::Reduce &);
private:
SemanticsContext &context_;
};
} // namespace Fortran::semantics
#endif // FORTRAN_SEMANTICS_CHECK_NAMELIST_H_