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
Conversation
@@ -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) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set_...
signifies a mutator.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it.
lib/semantics/check-do.cc
Outdated
if (checkedOptionalArg) { | ||
const evaluate::ActualArgument &checkedArg{*checkedOptionalArg}; | ||
const SomeExpr *checkedExpr{checkedArg.UnwrapExpr()}; | ||
if (evaluate::IsVariable(checkedExpr)) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
lib/semantics/semantics.cc
Outdated
void SemanticsContext::CheckDoVarRedefine( | ||
const Symbol &variable, const parser::CharBlock &location) { | ||
void SemanticsContext::CheckDoVarRedefine(const parser::CharBlock &location, | ||
const Symbol &variable, const parser::MessageFixedText message) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
lib/semantics/semantics.cc
Outdated
if (const Symbol * root{GetAssociationRoot(variable)}) { | ||
if (IsActiveDoVariable(*root)) { | ||
SayDoVarRedefine(location, *root); | ||
const parser::CharBlock doLoc{GetDoVariableLocation(*root)}; |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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.
…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
…/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
…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
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.