-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[SystemZ][z/OS] Add visibility features for z/OS (eg. _Export, pragma export) #111035
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
base: main
Are you sure you want to change the base?
Changes from 25 commits
e8d355c
6cf4355
e1cbba0
b23cfff
39a1411
9cfc3cc
e0cb769
82e9962
e7e560a
b5c7f01
b99182f
5d40056
266840a
1deb06a
5fb85ea
0fcfcfe
b54bd17
6ba783c
b407888
a1faeca
7871a6d
9672490
a156ebd
c6eb30f
5f0a685
a5187aa
507960b
aa8ffc7
34b2109
8432125
1198786
9e23c5d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -7504,6 +7504,27 @@ attribute requires a string literal argument to identify the handle being releas | |||||
}]; | ||||||
} | ||||||
|
||||||
def zOSExportDocs : Documentation { | ||||||
let Category = DocCatFunction; | ||||||
let Content = [{ | ||||||
Use the ``_Export`` keyword on a function or external variable to declare | ||||||
that it is to be exported (made available to other modules). You must define | ||||||
the object name in the same translation unit in which you use the ``_Export`` | ||||||
keyword. For example: | ||||||
|
||||||
.. code-block:: c | ||||||
|
||||||
int _Export anthony(float); | ||||||
|
||||||
This statement exports the function ``anthony``, if you define the function in the | ||||||
translation unit. The ``_Export`` keyword must immediately precede the declaration name. | ||||||
If you apply the ``_Export`` keyword to a class, the compiler automatically exports | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
What does it do with unions? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unions are handled the same way as classes or structs. Any member function or static data member of the union will be exported. |
||||||
all static data members and member functions of the class. However, if you want | ||||||
it to apply to individual class members, then you must apply it to each member | ||||||
that can be referenced. | ||||||
}]; | ||||||
} | ||||||
|
||||||
def UnsafeBufferUsageDocs : Documentation { | ||||||
let Category = DocCatFunction; | ||||||
let Content = [{ | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4459,6 +4459,11 @@ void Parser::ParseDeclarationSpecifiers( | |
isInvalid = DS.setFunctionSpecNoreturn(Loc, PrevSpec, DiagID); | ||
break; | ||
|
||
case tok::kw__Export: | ||
// We're done with the declaration-specifiers. | ||
goto DoneWithDeclSpec; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this mean There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
@perry-ca, I don't see any test in this PR for int (*_Export x)(void) = 0; Is the above accepted with this PR? Which conceptual model is being implemented here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The test case above is valid and exports x.
I'll add a test case to cover this. You are correct. This keyword is expected to appear right before the identifier of the symbol being exported. |
||
break; | ||
|
||
// friend | ||
case tok::kw_friend: | ||
if (DSContext == DeclSpecContext::DSC_class) { | ||
|
@@ -6774,6 +6779,17 @@ void Parser::ParseDeclaratorInternal(Declarator &D, | |
|
||
tok::TokenKind Kind = Tok.getKind(); | ||
|
||
// If this variable or function is marked as _Export, set the bit. | ||
if (Kind == tok::kw__Export) { | ||
SourceLocation loc = ConsumeToken(); | ||
D.SetExport(loc); | ||
D.SetRangeEnd(loc); | ||
|
||
if (DirectDeclParser) | ||
(this->*DirectDeclParser)(D); | ||
return; | ||
} | ||
|
||
if (D.getDeclSpec().isTypeSpecPipe() && !isPipeDeclarator(D)) { | ||
DeclSpec DS(AttrFactory); | ||
ParseTypeQualifierListOpt(DS); | ||
|
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.
This documentation should also mention the pragma spelling and document the whole thing. Also, do we diagnose that
anothony
isn't defined?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.
We don't diagnose that
anthony
isn't defined. This was never diagnosed in the existing z/OS compiler and neither with the visibility attribute. The wording is a little strong. We should say the object is only exported if it is also defined in the translation unit.