[PATCH] D79798: [flang] Constraint checks C751 to C760
Pete Steinfeld via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue May 12 15:37:40 PDT 2020
PeteSteinfeld requested review of this revision.
PeteSteinfeld marked 5 inline comments as done.
PeteSteinfeld added inline comments.
================
Comment at: flang/lib/Semantics/check-declarations.cpp:157
void CheckHelper::Check(const Symbol &symbol) {
+ // xmark
if (context_.HasError(symbol)) {
----------------
klausler wrote:
> ?
Oops. I'll remove this.
================
Comment at: flang/lib/Semantics/check-declarations.cpp:288
}
+ if (symbol.owner().IsDerivedType()) {
+ if (symbol.attrs().test(Attr::CONTIGUOUS) &&
----------------
klausler wrote:
> Why two `if` statements?
No reason. I'll combine them.
================
Comment at: flang/lib/Semantics/resolve-names.cpp:3909
}
-void DeclarationVisitor::Post(const parser::ProcComponentDefStmt &) {
+void DeclarationVisitor::Post(const parser::ProcComponentDefStmt &stmt) {
+ const auto &attrList{
----------------
klausler wrote:
> Can't this constraint be checked in `check-declarations.cpp`? If so, keep it out of name resolution.
Thanks, Peter. It looks like I can move it, and I will.
================
Comment at: flang/lib/Semantics/resolve-names.cpp:3915
+ if (std::get_if<parser::Pointer>(&attr.u)) {
+ foundPointer = true;
+ }
----------------
klausler wrote:
> Just `return` here, and remove the Boolean.
No longer necessary in the moved code.
================
Comment at: flang/test/Semantics/resolve33.f90:43
!ERROR: Must be a constant value
+ !ERROR: Invalid specification expression: derived type component not allowed to reference variable 'l'
character(kind=k, len=l) :: d3
----------------
tskeith wrote:
> klausler wrote:
> > This error seems spurious to me. We know that `l` (lower-case letter ell) is a type parameter.
> Yes, the "Must be a constant value" error too. The real errors are the ones above: "No definition found for type parameter".
>
> Setting and checking the `Error` flag on the symbols for `k` and `l` might be a way to avoid these.
Constraint C754 states that a type-param-value in a component-def-stmt shall not depend on the value of a variable. In this case, the type-param-value of "len" depends on "l" (lower case ell), which is a variable. But the message incorrectly says that the expression is associated with a derived type component.
Note that the constraints on specification expressions in derived types are identical for bounds expressions of components and for values of type parameters. Do you think it's important that the error messages distinguish these two cases?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D79798/new/
https://reviews.llvm.org/D79798
More information about the llvm-commits
mailing list