The entity with BIND(C) attribute cannot be a named constant, so the
BIND(C) and parameter attributes are conflicted. Add check for it.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Are you checking constraint C818? That constraint lists four things that a BIND(C) item can be. It might be more effective to verify that a BIND(C) entity is one of those four things rather than trying to check that it is not any of the many other possibilities.
The BIND(C) can only be in type-declaration-stmt, bind-stmt, or proc-language-binding-spec. I think there is no need to check C818 since those does not satisfy C818 will fail in parser with the exception of named constant. Also the pointer and allocatable variables cannot have BIND(C) attribute.
The other semantic checks for bind-stmt and proc-language-binding-spec will be later work. The semantic checks for Section 8.5.5 should be done after this patch.
BTW, I checked the conflict of all the attributes in type-declaration-stmt for BIND(C). The parameter and allocatable attributes can be deduced to be conflicted with BIND(C). For pointer attribute, I don't find the restriction in the standard. gfortran and ifort report the errors.
Pointers and allocatables are not allowed as components in derived types with BIND(C), but there's no such restriction on variables in the standard, and the interoperable descriptor has features to support both pointers and allocatables.
Pointers and allocatables are not allowed as components in derived types with BIND(C), but there's no such restriction on variables in the standard
BIND(C) is not allowed as components in derived types. This will fail in parser.
the interoperable descriptor has features to support both pointers and allocatables.
Thanks for letting me know this. I will go forward with that after going through the semantic analysis of interoperability.
I know, but that's not what I was addressing. BIND(C) is allowed on the derived type itself, and this has consequences of the semantics of the components.
I know, but that's not what I was addressing. BIND(C) is allowed on the derived type itself, and this has consequences of the semantics of the components.
Oh. Sorry, I misunderstood. Got what you mean.
I checked all the cases for C818. The entity does not satify C818 fails in parser or the semantic checks have been supported before. It seems the named constant is the only exception. Maybe I miss something? The named constant is kind of like special case, such as its usage in common block, function result, or with the bind(c) attribute. The standard usually does not decribe it on purpose. Instead, the standard usually states "a variable" to exclude the named constant. I think these checks are missed since the named constant and variable both have ObjectEntity detail, but they are different. Maybe there are still somewhere missing this check.