explicit keyword is declared outside of class is invalid, invalid explicit declaration is handled inside DiagnoseFunctionSpecifiers() function. To avoid compiler crash in case of invalid explicit declaration, remove assertion.
Details
Diff Detail
- Repository
- rC Clang
Event Timeline
clang/test/Misc/explicit.c | ||
---|---|---|
1 ↗ | (On Diff #279908) | This is missing a RUN line and thus doesn't test anything |
We already check that explicit is only used in the proper scopes in ActOnFunctionDeclarator (and the proper scopes aren't just class scopes, due to deduction guides). In fact, the assert appears to have nothing to do with whether the expression appears at function scope; that's a red herring caused by unary && (address of label) doing different things at that scope. An analogous case crashes at class scope too:
void *p; struct X { explicit(p) X(); };
It looks like this is just a bogus assertion; when ActOnExplicitBoolSpecifier produces an invalid ExplicitSpecifier and the parser stores it on the DeclSpec, the assertion that's triggering is in effect asserting that the ExplicitSpecifier is not invalid, which seems wrong, because it certainly can be invalid. We'll need to check that later users of the ExplicitSpecifier can cope with it being invalid, but subject to that, removing the assertion seems like the right change to me.
Yes, I agree, declaration of explicit is varified inside ActOnFunctionDeclarator(), removing the assertion looks correct.
Yes,
Please use these details to commit.
My Github username: gousemoodhin
My GitHub email id: nadafgouse5@gmail.com