Skip to content
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

Add Linkage section #249

Merged
merged 4 commits into from
Jun 11, 2024
Merged

Add Linkage section #249

merged 4 commits into from
Jun 11, 2024

Conversation

hekota
Copy link
Member

@hekota hekota commented May 29, 2024

Create chapter file for Declarations and add section about linkage. Enumerate the language defaults and where it is implementation dependent. Add empty chapter file for Statements to preserve the chapter ordering.

@hekota hekota changed the title Create Statements and Declarations chapter files; add note about default linkage Create chapter files for Statements and Declarations; add note about default linkage May 29, 2024
@hekota hekota changed the title Create chapter files for Statements and Declarations; add note about default linkage Add Linkage section Jun 5, 2024
Copy link
Collaborator

@llvm-beanz llvm-beanz left a comment

Choose a reason for hiding this comment

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

In the cases of external and internal linkage there's also a property where a declaration inherits the linkage of its encompassing declaration. For example:

namespace PublicStuff {
  void Fn(int); // external linkage
  
  class Obj {
    void MemberFn(); // external linkage
  }; // external linkage
}

namespace {
  void Fn(int); // internal linkage
  
  class Obj {
    void MemberFn(); // internal linkage
  }; // internal linkage
}

This isn't true for all declarations. For example declarations in function-scope and scopes that derive from function-scope are always no-linkage unless they are static.

specs/language/declarations.tex Outdated Show resolved Hide resolved
specs/language/declarations.tex Outdated Show resolved Hide resolved
@hekota
Copy link
Member Author

hekota commented Jun 8, 2024

In the cases of external and internal linkage there's also a property where a declaration inherits the linkage of its encompassing declaration. For example:

namespace PublicStuff {
  void Fn(int); // external linkage
  
  class Obj {
    void MemberFn(); // external linkage
  }; // external linkage
}

namespace {
  void Fn(int); // internal linkage
  
  class Obj {
    void MemberFn(); // internal linkage
  }; // internal linkage
}

DXC currently does not support unnamed namespaces, that's why I did not include it here.

This isn't true for all declarations. For example declarations in function-scope and scopes that derive from function-scope are always no-linkage unless they are static.

I believe this is described in the No Linkage section under the term block-scope. I can add more details to that section to make it clearer.

Copy link
Collaborator

@llvm-beanz llvm-beanz left a comment

Choose a reason for hiding this comment

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

LGTM. I think we may need to tweak some of this in the future but I think this is pretty good.

@hekota hekota merged commit b4e5d9e into microsoft:main Jun 11, 2024
3 checks passed
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.

4 participants