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

cheri_compartment: Warn if return type is void or return value is unused #79

Closed

Conversation

resistor
Copy link
Collaborator

Reapply #47

Changes since that version:

  • **Squashed history.
  • **Removed early return that caused link errors.
  • **Disable. warning by default while CheriotRTOS transitions.

v01dxyz and others added 3 commits December 17, 2024 18:18
The current implementation has a little shortcoming: the warning
message for void return type is shown twice because cheri_compartment
is a function type attribute (cf SemaType.cpp) that is added to both
the attribute list of the declarator and the one of the function type.
@resistor
Copy link
Collaborator Author

@v01dXYZ

@resistor
Copy link
Collaborator Author

@v01dXYZ

Changes all look ok to you?

static void handleCHERICompartmentName(Sema &S, Decl *D, const ParsedAttr &Attr) {
static void handleCHERICompartmentName(Sema &S, Decl *D, const ParsedAttr &Attr,
Sema::DeclAttributeLocation DAL) {
// cheri_compartment is both:
Copy link

Choose a reason for hiding this comment

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

I think we need to handle the attribute only at the DeclSpec level and not in the DeclChunk one. Otherwise, it generates duplicate messages.

Copy link

@v01dXYZ v01dXYZ Dec 17, 2024

Choose a reason for hiding this comment

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

Oh that's the part that lead to the linking error ! I'll try to recreate the function declaration/definition where the attribute is skipped by this early return.

Copy link

Choose a reason for hiding this comment

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

I think I've got the gotcha. An attribute after a pointer return type remains tied to the DeclChunk (void * __attribute__((...))). So my code was wrong.

Copy link

@v01dXYZ v01dXYZ Dec 17, 2024

Choose a reason for hiding this comment

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

maybe I should do the way round, ie only process the DeclChunks.

@resistor
Copy link
Collaborator Author

Feel free to pull this branch into your repo and make your own PR with the correct version.

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