Skip to content
Snippets Groups Projects
Commit 0fd19e48 authored by Andre Maroneze's avatar Andre Maroneze
Browse files

Merge branch 'feature/kernel/cast-pointer-to-integer' into 'master'

[Kernel] Warns when converting a pointer into an integer without an explicit cast.

Closes #548

See merge request frama-c/frama-c!2172
parents 7ca00ea0 1831f0f3
No related branches found
No related tags found
No related merge requests found
...@@ -51,6 +51,6 @@ void main1(int c){ ...@@ -51,6 +51,6 @@ void main1(int c){
int X1; int X1;
int* X2; int* X2;
X1 = X2; X1 = (int) X2;
} }
...@@ -43,5 +43,5 @@ void main () { ...@@ -43,5 +43,5 @@ void main () {
s2 = s1; // Creates a garbled mix internally; make sure not to log it s2 = s1; // Creates a garbled mix internally; make sure not to log it
s2.a = s2.c + (int) s2.c; // creates a garbled mix in the struct s2.a = (int) (s2.c + (int) s2.c); // creates a garbled mix in the struct
} }
...@@ -12,7 +12,7 @@ struct st1 { ...@@ -12,7 +12,7 @@ struct st1 {
}; };
int *outp; int *outp;
int x,y,z1,z2,z3,z4; int x,y,z1,z2,z3,z4;
struct st1 T[22] = { {1,2,0,&x}, {&z1,&z2,&z3,&y},{&z4,2,0,&x},{1,2,0,&x} }; struct st1 T[22] = { {1,2,0,&x}, {(int)&z1,(int)&z2,&z3,&y},{(int)&z4,2,0,&x},{1,2,0,&x} };
struct S { struct S {
int a; int a;
......
...@@ -25,9 +25,9 @@ struct st1 s8,s7; ...@@ -25,9 +25,9 @@ struct st1 s8,s7;
long x,y,z,t; volatile int v; long x,y,z,t; volatile int v;
void main () { void main () {
x = &s1.d[9]; x = (long) &s1.d[9];
y = &s1.d[10]; y = (long) &s1.d[10];
z = &s1.b; z = (long) &s1.b;
......
...@@ -51,7 +51,7 @@ void main4_scope_right() { ...@@ -51,7 +51,7 @@ void main4_scope_right() {
unsigned int i = v; //@ assert i <= 8; unsigned int i = v; //@ assert i <= 8;
{ {
int x; int x;
t[i] = &x; t[i] = (int) &x;
Frama_C_dump_each(); Frama_C_dump_each();
} }
Frama_C_dump_each(); // Should be empty, x out-of-scope Frama_C_dump_each(); // Should be empty, x out-of-scope
......
...@@ -80,7 +80,7 @@ int * volatile main2() { ...@@ -80,7 +80,7 @@ int * volatile main2() {
int * volatile p1, * volatile p2, * volatile p3; int * volatile p1, * volatile p2, * volatile p3;
p1 = G ? 0 : &X; p1 = G ? 0 : &X;
p2 = &X; p2 = &X;
k = G ? 0 : &X; k = G ? 0 : (int) &X;
p3 = k; p3 = k;
return k; return k;
} }
......
...@@ -28,7 +28,7 @@ void main() { ...@@ -28,7 +28,7 @@ void main() {
char *q1 = p->f4.f1; char *q1 = p->f4.f1;
int *q2 = p->f4.f2; int *q2 = p->f4.f2;
int i = p->f5; int i = p->f5;
int j = p->f4.f2; int j = (int) p->f4.f2;
int r = (&x - p->f4.f1)+1; int r = (&x - p->f4.f1)+1;
int s = (&y - p->f4.f2)+3; int s = (&y - p->f4.f2)+3;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment