Skip to content

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

Merged
merged 16 commits into from
Feb 18, 2019
Merged

Structure constructor semantics #287

merged 16 commits into from
Feb 18, 2019

Conversation

klausler
Copy link
Collaborator

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.

PutLower(decls_ << ",extends(", details.extends().ToString()) << ')';
if (const DerivedTypeSpec * extends{typeSymbol.GetParentTypeSpec()}) {
PutLower(decls_ << ",extends(", extends->typeSymbol().name().ToString())
<< ')';
Copy link
Collaborator

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()) << ')';

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thank you.

// order. A parent component, if any, appears first in this list.
std::list<const Symbol *> components_;
SourceName extends_;
std::list<SourceName> components_;
Copy link
Collaborator

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure.

if (symbol.test(Symbol::Flag::ParentComp)) {
CHECK(result.empty());
const DerivedTypeSpec &spec{
*symbol.get<ObjectEntityDetails>().type()->AsDerived()};
Copy link
Collaborator

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().

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; fixed it here and in one other place that I found.

Copy link
Collaborator

@tskeith tskeith left a comment

Choose a reason for hiding this comment

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

Looks good

@klausler klausler merged commit b1a8222 into master Feb 18, 2019
@klausler klausler deleted the pmk-struct branch February 18, 2019 22:16
mem-frob pushed a commit to draperlaboratory/hope-llvm-project that referenced this pull request Oct 7, 2022
Original-commit: flang-compiler/f18@7131a2f
Reviewed-on: flang-compiler/f18#287
Tree-same-pre-rewrite: false
mem-frob pushed a commit to draperlaboratory/hope-llvm-project that referenced this pull request Oct 7, 2022
mem-frob pushed a commit to draperlaboratory/hope-llvm-project that referenced this pull request Oct 7, 2022
mem-frob pushed a commit to draperlaboratory/hope-llvm-project that referenced this pull request Oct 7, 2022
mem-frob pushed a commit to draperlaboratory/hope-llvm-project that referenced this pull request Oct 7, 2022
Original-commit: flang-compiler/f18@03944d5
Reviewed-on: flang-compiler/f18#287
Tree-same-pre-rewrite: false
mem-frob pushed a commit to draperlaboratory/hope-llvm-project that referenced this pull request Oct 7, 2022
mem-frob pushed a commit to draperlaboratory/hope-llvm-project that referenced this pull request Oct 7, 2022
Original-commit: flang-compiler/f18@156791b
Reviewed-on: flang-compiler/f18#287
Tree-same-pre-rewrite: false
mem-frob pushed a commit to draperlaboratory/hope-llvm-project that referenced this pull request Oct 7, 2022
Original-commit: flang-compiler/f18@fc807bf
Reviewed-on: flang-compiler/f18#287
Tree-same-pre-rewrite: false
mem-frob pushed a commit to draperlaboratory/hope-llvm-project that referenced this pull request Oct 7, 2022
Original-commit: flang-compiler/f18@6146957
Reviewed-on: flang-compiler/f18#287
Tree-same-pre-rewrite: false
mem-frob pushed a commit to draperlaboratory/hope-llvm-project that referenced this pull request Oct 7, 2022
Original-commit: flang-compiler/f18@d90d5d9
Reviewed-on: flang-compiler/f18#287
Tree-same-pre-rewrite: false
mem-frob pushed a commit to draperlaboratory/hope-llvm-project that referenced this pull request Oct 7, 2022
Original-commit: flang-compiler/f18@e66ef36
Reviewed-on: flang-compiler/f18#287
Tree-same-pre-rewrite: false
mem-frob pushed a commit to draperlaboratory/hope-llvm-project that referenced this pull request Oct 7, 2022
mem-frob pushed a commit to draperlaboratory/hope-llvm-project that referenced this pull request Oct 7, 2022
mem-frob pushed a commit to draperlaboratory/hope-llvm-project that referenced this pull request Oct 7, 2022
mem-frob pushed a commit to draperlaboratory/hope-llvm-project that referenced this pull request Oct 7, 2022
Original-commit: flang-compiler/f18@17dc735
Reviewed-on: flang-compiler/f18#287
Tree-same-pre-rewrite: false
mem-frob pushed a commit to draperlaboratory/hope-llvm-project that referenced this pull request Oct 7, 2022
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.

2 participants