forked from checkedc/checkedc-clang
-
Notifications
You must be signed in to change notification settings - Fork 5
Convert root_cause test to use Clang's built-in diagnostic verifier. #365
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,55 +1,43 @@ | ||
| // RUN: 3c -extra-arg="-Wno-everything" -alltypes -warn-root-cause %s 2>&1 >%t.unused | FileCheck %s | ||
| // RUN: 3c -extra-arg="-Wno-everything" -verify -alltypes -warn-root-cause %s | ||
|
|
||
| // This test is unusual in that it checks for the errors in the code | ||
|
|
||
| #include <stddef.h> | ||
| extern _Itype_for_any(T) void *malloc(size_t size) : itype(_Array_ptr<T>) byte_count(size); | ||
|
|
||
| void *x; | ||
| // CHECK-DAG: Default void* type | ||
| void *x; // expected-warning {{Default void* type}} | ||
|
|
||
| void test0() { | ||
| int *a; | ||
| char *b; | ||
| a = b; | ||
| // CHECK-DAG: Cast from int * to char * | ||
| a = b; // expected-warning {{Cast from char * to int *}} | ||
|
|
||
| int *c; | ||
| (char*) c; | ||
| // CHECK-DAG: Cast from int * to char * | ||
| (char*) c; // expected-warning {{Cast from int * to char *}} | ||
|
|
||
|
|
||
| int *e; | ||
| char *f; | ||
| f = (char*) e; | ||
| // CHECK-DAG: Cast from char * to int * | ||
| f = (char*) e; // expected-warning {{Cast from int * to char *}} | ||
| } | ||
|
|
||
| void test1() { | ||
| int a; | ||
| int *b; | ||
| b = malloc(sizeof(int)); | ||
| b = malloc(sizeof(int)); // expected-warning {{Bad pointer type solution}} | ||
| b[0] = 1; | ||
|
|
||
| union u { | ||
| int *a; | ||
| // CHECK-DAG: Union or external struct field encountered | ||
| int *b; | ||
| // CHECK-DAG: Union or external struct field encountered | ||
| int *a; // expected-warning {{Union or external struct field encountered}} | ||
| int *b; // expected-warning {{Union or external struct field encountered}} | ||
| }; | ||
|
|
||
| void (*c)(void); | ||
| c++; | ||
| // CHECK-DAG: Pointer arithmetic performed on a function pointer | ||
| c++; // expected-warning {{Pointer arithmetic performed on a function pointer}} | ||
|
|
||
| int *d = malloc(1); | ||
| // CHECK-DAG: Unsafe call to allocator function | ||
| int *d = malloc(1); // expected-warning {{Unsafe call to allocator function}} | ||
| } | ||
|
|
||
| extern int *glob; | ||
| // CHECK-DAG: External global variable glob has no definition | ||
| extern int *glob; // expected-warning {{External global variable glob has no definition}} | ||
|
|
||
| void (*f)(void *); | ||
| // CHECK-DAG: Default void* type | ||
|
|
||
| // CHECK-DAG: 11 warnings generated. | ||
| void (*f)(void *); // expected-warning {{Default void* type}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 is a regression to when we didn't know about %t temp files. Which admittedly may have been so soon that the changes overlapped. If there's no reason for the regressions, lets leave the simpler code that doesn't create extra files if it ends prematurely.
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.
%texpanded to a filename ending in.c.tmp. For some reason,3cdoesn't like that as an input file name and spewed a bunch of errors. For now, I just changed this test to do the same thing as many of our other tests. When we have a proper solution to this problem, we can update all the tests.I'm sorry for not giving you more time to review this.
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.
It didn't give me any errors when I committed it. Is that because of tests on a different system, or related to the changes made in this pull request?
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.
Before this pull request, when I ran the
3ccommand from theRUNline manually, I saw the errors, but3cstill exited 0, so the test passed, andlitdoesn't seem to show the stderr of passing tests. With the changes in this pull request,3cexited 1, so I had to do something about the test.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 seems significant to me, maybe for more issues? One for
.tmpand one for passing with errors. If 3c ever allows tests to pass that have errors in them, that's bad for everyone. Did this pull request fix all of that? The OP was concerned with a subset and then you fixed more.I guess for now we need to remember not to pass lit temp files to 3c. I'll see if there's a good place to fit that in the temp files issue I made earlier to document future changes.
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.
Agreed!
I'm not sure, and I don't really want to spend more time researching it right now. Someone else is probably more familiar than I am with all the types of errors that can occur in 3c.
Good. If we pass a temp file, the test will fail, and we just need to learn quickly that it is because of the temp file and not waste time debugging again.