Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for passing DO variables to OUT arguments in a CALL statement #902

Merged
merged 1 commit into from Jan 3, 2020

Conversation

psteinfeld
Copy link
Collaborator

I added code to save the INTENT of a dummy argument in the checked expression
of the actual argument. When processing a CallStmt, I then retrieve the
ProcedureRef, which contains a list of the checked ActualArguments. I then
traverse this list looking for actual arguments that are active DO variable
that are being passed to dummy arguments whose INTENT is either OUT or INOUT.
For OUT dummies, I put out an error message and warn for INOUT dummies.

@@ -111,6 +111,11 @@ class ActualArgument {
void set_isPassedObject(bool yes = true) { isPassedObject_ = yes; }

bool Matches(const characteristics::DummyArgument &) const;
common::Intent dummyIntent() const { return dummyIntent_; }
ActualArgument &set_dummyIntent(common::Intent intent) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why mix camelCase and underscores?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see other instances of this. Is this done intentionally?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set_... signifies a mutator.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The data member is called "dummyIntent_" and I wanted a mutator for it. Our style guide says that mutators should start with "set_" followed by the name of the data member without the underscore. The result is this mix of camelCase and underscores.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it.

if (checkedOptionalArg) {
const evaluate::ActualArgument &checkedArg{*checkedOptionalArg};
const SomeExpr *checkedExpr{checkedArg.UnwrapExpr()};
if (evaluate::IsVariable(checkedExpr)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

evaluate::UnwrapWholeSymbolDataRef() would be better, if you just need a tool that determines whether a typed Expr is nothing more that a reference to a single Symbol.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, Peter. I'll change it.

void SemanticsContext::CheckDoVarRedefine(
const Symbol &variable, const parser::CharBlock &location) {
void SemanticsContext::CheckDoVarRedefine(const parser::CharBlock &location,
const Symbol &variable, const parser::MessageFixedText message) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Slightly better to use parser::MessageFixedText &&message and then std::move it where it is used.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, Tim. I'll change this.

if (const Symbol * root{GetAssociationRoot(variable)}) {
if (IsActiveDoVariable(*root)) {
SayDoVarRedefine(location, *root);
const parser::CharBlock doLoc{GetDoVariableLocation(*root)};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't normally declare local variables const.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, Tim. I'll change my recent declarations of local variables.

I added code to save the INTENT of a dummy argument in the checked expression
of the actual argument.  When processing a CallStmt, I then retrieve the
ProcedureRef, which contains a list of the checked ActualArguments.  I then
traverse this list looking for actual arguments that are active DO variable
that are being passed to dummy arguments whose INTENT is either OUT or INOUT.
For OUT dummies, I put out an error message and warn for INOUT dummies.
@psteinfeld psteinfeld merged commit 2722066 into master Jan 3, 2020
@psteinfeld psteinfeld deleted the ps-do-call branch January 3, 2020 17:09
swift-ci pushed a commit to apple/llvm-project that referenced this pull request Apr 9, 2020
…tement

I added code to save the INTENT of a dummy argument in the checked expression
of the actual argument.  When processing a CallStmt, I then retrieve the
ProcedureRef, which contains a list of the checked ActualArguments.  I then
traverse this list looking for actual arguments that are active DO variable
that are being passed to dummy arguments whose INTENT is either OUT or INOUT.
For OUT dummies, I put out an error message and warn for INOUT dummies.

Original-commit: flang-compiler/f18@0ff1d26
Reviewed-on: flang-compiler/f18#902
swift-ci pushed a commit to apple/llvm-project that referenced this pull request Apr 9, 2020
…/ps-do-call

Check for passing DO variables to OUT arguments in a CALL statement

Original-commit: flang-compiler/f18@2722066
Reviewed-on: flang-compiler/f18#902
mem-frob pushed a commit to draperlaboratory/hope-llvm-project that referenced this pull request Oct 7, 2022
…tement

I added code to save the INTENT of a dummy argument in the checked expression
of the actual argument.  When processing a CallStmt, I then retrieve the
ProcedureRef, which contains a list of the checked ActualArguments.  I then
traverse this list looking for actual arguments that are active DO variable
that are being passed to dummy arguments whose INTENT is either OUT or INOUT.
For OUT dummies, I put out an error message and warn for INOUT dummies.

Original-commit: flang-compiler/f18@0ff1d26
Reviewed-on: flang-compiler/f18#902
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants