-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[clang] move -Wcast-function-type under -Wextra #77178
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
Changes from 1 commit
d147292
386ea16
d14a0dc
daa462a
eb8ad4f
b2c2569
3774838
f07fb78
1cccdb8
ec4c425
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 | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,42 @@ | ||||||
| // RUN: %clang_cc1 %s -fsyntax-only -Wextra -verify | ||||||
|
||||||
|
|
||||||
|
|
||||||
| int t(int array[static 12]); | ||||||
| int u(int i); | ||||||
| const int v(int i); /* expected-warning {{'const' type qualifier on return type has no effec}} */ | ||||||
|
||||||
| const int v(int i); /* expected-warning {{'const' type qualifier on return type has no effec}} */ | |
| const int v(int i); /* expected-warning {{'const' type qualifier on return type has no effect}} */ |
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.
Didn't have to do it as the file is now not added.
Outdated
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.
On line 6 we issue a diagnostic that const qualifier doesn't have effect on return type, yet we issue a diagnostic here telling that this makes function pointer type incompatible. It feels like we fail to make up our minds on the matter, or that we are overly pedantic without pedantic warnings enabled.
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.
Yeah, even I found this strange. Is there a place we can verify which is the correct behavior?
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.
I hope @AaronBallman can clarify.
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.
I think the diagnostic here is incorrect.
C23 6.7.6.3p4:
If, in the declaration "T D1", D1 has the form
D ( parameter-type-listopt ) attribute-specifier-sequenceopt
and the type specified for ident in the declaration "T D" is "derived-declarator-type-list T", then the
type specified for ident is "derived-declarator-type-list function returning the unqualified, non-atomic
version of T". The optional attribute specifier sequence appertains to the function type.
So the type of the function does not include the qualifiers on the return type, which means that const int f(void) and int f(void) should result in the same type.
We get this wrong: https://godbolt.org/z/xvh449xrd
I think this is a more general problem with how we model the function type: https://godbolt.org/z/G3vxjW9dh
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.
So, create an issue? Comment out this test case and put a comment relating to the new issue?
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.
No need to create an issue, we've already got one: #39494
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.
Probably worth it to add a FIXME comment above the test case and point to that issue, though.
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.
So finally the things. I need to do:
Add FIXME comment and leave the test case as is. Remove the clang/test/Sema/warn-extra-cast-function-type-strict.c file . Update release notes. Then update the pull request. Agree? @nickdesaulniers @AaronBallman @Endilll @shafik
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.
That sounds correct to me
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.
Done.
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.
As written, tests checks only default language mode for C (which is
gnu99AFAIK). Maybe we want to check other modes as well?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.
add runs for -std=cNN for all remaining 5 of them? and also add extra test cases where conflicts arise?
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.
Yes, more
RUNlines with different-std=options, and potentially moreexpecteddirectives tailored for particular language mode. We have an example of this in C++ defect report tests: https://github.com/llvm/llvm-project/blob/main/clang/test/CXX/drs/dr6xx.cppNote that I might be biased here, as someone who've spent a significant time with C++ defect report test suite.