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

Cpp: Fix the unused parameter warning in the sempred function. #4171

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

0xFireWolf
Copy link
Contributor

Consider the following simple grammar:

Expression : Expression '*' Expression
           | Expression '+' Expression

ANTLR will generate the following member function:

bool SampleParser::expressionSempred(ExpressionContext *_localctx, size_t predicateIndex)
{
    switch (predicateIndex) 
    {
        case 0: return precpred(_ctx, 5);
        case 1: return precpred(_ctx, 4);

        default:
        break;
    }
    return true;
}

The first parameter is never used in the function body, resulting in an unused parameter warning. This PR fixes the warning by adding the attribute [[maybe_unused]] which is available as of C++17.

Thank you.

Signed-off-by: FireWolf <austere.j@gmail.com>
@parrt
Copy link
Member

parrt commented Mar 29, 2023

Hi. thanks. can you remind me of the min C++ version we require?

@0xFireWolf
Copy link
Contributor Author

Hi. thanks. can you remind me of the min C++ version we require?

I think it is C++17.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants