-
Notifications
You must be signed in to change notification settings - Fork 49
Structure constructor semantics #287
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
Conversation
lib/semantics/mod-file.cc
Outdated
PutLower(decls_ << ",extends(", details.extends().ToString()) << ')'; | ||
if (const DerivedTypeSpec * extends{typeSymbol.GetParentTypeSpec()}) { | ||
PutLower(decls_ << ",extends(", extends->typeSymbol().name().ToString()) | ||
<< ')'; |
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.
There is an overloading of PutLower
that takes a symbol instead of a name:
PutLower(decls_ << ",extends(", extends->typeSymbol()) << ')';
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.
Thank you.
lib/semantics/symbol.h
Outdated
// order. A parent component, if any, appears first in this list. | ||
std::list<const Symbol *> components_; | ||
SourceName extends_; | ||
std::list<SourceName> components_; |
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.
componentNames_
might be a better name for this field. In the functions OrderComponents()
and GetParentComponent()
, "component" means component symbol, not name.
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.
Sure.
lib/semantics/symbol.cc
Outdated
if (symbol.test(Symbol::Flag::ParentComp)) { | ||
CHECK(result.empty()); | ||
const DerivedTypeSpec &spec{ | ||
*symbol.get<ObjectEntityDetails>().type()->AsDerived()}; |
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.
Since you're assuming the type is a derived type, you could use symbol.get<ObjectEntityDetails>().type()->derivedTypeSpec()
. It asserts it is a derived type and returns a reference.
Maybe we shouldn't have both AsDerived()
and derivedTypeSpec()
.
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; fixed it here and in one other place that I found.
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.
Looks good
Original-commit: flang-compiler/f18@7131a2f Reviewed-on: flang-compiler/f18#287 Tree-same-pre-rewrite: false
…omponent list Original-commit: flang-compiler/f18@1515022 Reviewed-on: flang-compiler/f18#287 Tree-same-pre-rewrite: false
Original-commit: flang-compiler/f18@9d60038 Reviewed-on: flang-compiler/f18#287 Tree-same-pre-rewrite: false
Original-commit: flang-compiler/f18@47986f0 Reviewed-on: flang-compiler/f18#287 Tree-same-pre-rewrite: false
Original-commit: flang-compiler/f18@03944d5 Reviewed-on: flang-compiler/f18#287 Tree-same-pre-rewrite: false
Original-commit: flang-compiler/f18@b0a574f Reviewed-on: flang-compiler/f18#287 Tree-same-pre-rewrite: false
Original-commit: flang-compiler/f18@156791b Reviewed-on: flang-compiler/f18#287 Tree-same-pre-rewrite: false
Original-commit: flang-compiler/f18@fc807bf Reviewed-on: flang-compiler/f18#287 Tree-same-pre-rewrite: false
Original-commit: flang-compiler/f18@6146957 Reviewed-on: flang-compiler/f18#287 Tree-same-pre-rewrite: false
Original-commit: flang-compiler/f18@d90d5d9 Reviewed-on: flang-compiler/f18#287 Tree-same-pre-rewrite: false
Original-commit: flang-compiler/f18@e66ef36 Reviewed-on: flang-compiler/f18#287 Tree-same-pre-rewrite: false
Original-commit: flang-compiler/f18@8a081e8 Reviewed-on: flang-compiler/f18#287 Tree-same-pre-rewrite: false
Original-commit: flang-compiler/f18@e6178b2 Reviewed-on: flang-compiler/f18#287 Tree-same-pre-rewrite: false
Original-commit: flang-compiler/f18@03fcb58 Reviewed-on: flang-compiler/f18#287 Tree-same-pre-rewrite: false
Original-commit: flang-compiler/f18@17dc735 Reviewed-on: flang-compiler/f18#287 Tree-same-pre-rewrite: false
Original-commit: flang-compiler/f18@7662121 Reviewed-on: flang-compiler/f18#287
Semantic analysis, representation, and folding of structure constructors. The semantic analysis is performed during expression semantics, so that the code will be in the right place after generic function call resolution is implemented.
Constants got a lot of working over, and constant Character objects are now in their own template specialization. Constant character array elements are no longer distinct std::strings, but are instead all packed into one string in Fortran element order, anticipating their use in folding of transformational intrinsics. (Constant derived type values are not yet packed in storage.)
Some further work on array constructors was done after taking a few passes with this code over some regression test suites. A language extension implemented by PGI and another compiler was discovered and now supported regarding character array constructors with distinct lengths on their character literals.
Some TODOs remain with structure and array constructors with regard to type conformance checking; that'll come next week.