forked from checkedc/checkedc-clang
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #365 from correctcomputation/root-cause-test-line-…
…numbers Convert root_cause test to use Clang's built-in diagnostic verifier.
- Loading branch information
Showing
5 changed files
with
87 additions
and
45 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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