Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/incremental/compareAST.ml
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,15 @@ and eq_typ_acc (a: typ) (b: typ) ~(acc: (typ * typ) list) ~(rename_mapping: rena
else (
let acc = (a, b) :: acc in
let res = eq_compinfo compinfo1 compinfo2 acc rename_mapping && GobList.equal (eq_attribute ~rename_mapping ~acc) attr1 attr2 in
if res && compinfo1.cname <> compinfo2.cname then
compinfo2.cname <- compinfo1.cname;
if res then
if res then begin
global_typ_acc := (a, b) :: !global_typ_acc;

(* Reset cnames and ckeys to the old value. Only affects anonymous structs/unions where names are not checked for equality. *)
if compinfo1.cname <> compinfo2.cname then
compinfo2.cname <- compinfo1.cname;
if compinfo1.ckey <> compinfo2.ckey then
compinfo2.ckey <- compinfo1.ckey;
end;
res
)
| TEnum (enuminfo1, attr1), TEnum (enuminfo2, attr2) -> let res = eq_enuminfo enuminfo1 enuminfo2 ~rename_mapping ~acc && GobList.equal (eq_attribute ~rename_mapping ~acc) attr1 attr2 in (if res && enuminfo1.ename <> enuminfo2.ename then enuminfo2.ename <- enuminfo1.ename); res
Expand Down
33 changes: 33 additions & 0 deletions tests/incremental/00-basic/13-anonymous-compound.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include <pthread.h>

typedef struct foo_struct {
union {
int i;
struct inner_struct {
int head, tail;
} coin;
};
} foo_t;

foo_t str;

void *read(void *ptr){
int x = str.coin.head; // RACE!
int a = 32;
return NULL;
}

void *write(void *ptr){
str.coin.head = 23; // RACE!
return NULL;
}

int main(){
pthread_t r;
pthread_t w;

pthread_create(&w, NULL, write, NULL);
pthread_create(&r, NULL, read, NULL);

return 0;
}
2 changes: 2 additions & 0 deletions tests/incremental/00-basic/13-anonymous-compound.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{
}
34 changes: 34 additions & 0 deletions tests/incremental/00-basic/13-anonymous-compound.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
diff --git tests/incremental/00-basic/13-anonymous-compound.c tests/incremental/00-basic/13-anonymous-compound.c
index 3e2d7b527..81f3e704a 100644
--- tests/incremental/00-basic/13-anonymous-compound.c
+++ tests/incremental/00-basic/13-anonymous-compound.c
@@ -1,5 +1,21 @@
#include <pthread.h>

+
+typedef struct foo_bar {
+ int x;
+ int y;
+} foo_bar_t;
+
+typedef struct bar {
+ union{
+ int x;
+ struct inner {
+ int a;
+ int b;
+ } i;
+ } un;
+} bar_t;
+
typedef struct foo_struct {
union {
int i;
@@ -13,6 +29,7 @@ foo_t str;

void *read(void *ptr){
int x = str.coin.head; // RACE!
+ int y = str.coin.head; // RACE!
int a = 32;
return NULL;
}
33 changes: 33 additions & 0 deletions tests/incremental/00-basic/14-struct.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include <pthread.h>

typedef struct foo_struct {
union {
int i;
struct inner_struct {
int head, tail;
} coin;
} un;
} foo_t;

foo_t str;

void *read(void *ptr){
int x = str.un.coin.head; // RACE!
int a = 32;
return NULL;
}

void *write(void *ptr){
str.un.coin.head = 23; // RACE!
return NULL;
}

int main(){
pthread_t r;
pthread_t w;

pthread_create(&w, NULL, write, NULL);
pthread_create(&r, NULL, read, NULL);

return 0;
}
2 changes: 2 additions & 0 deletions tests/incremental/00-basic/14-struct.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{
}
23 changes: 23 additions & 0 deletions tests/incremental/00-basic/14-struct.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
diff --git tests/incremental/00-basic/14-struct.c tests/incremental/00-basic/14-struct.c
index 6eadc7a57..568a90aed 100644
--- tests/incremental/00-basic/14-struct.c
+++ tests/incremental/00-basic/14-struct.c
@@ -1,5 +1,10 @@
#include <pthread.h>

+typedef struct foo_bar {
+ int x;
+ int y;
+} foo_bar_t;
+
typedef struct foo_struct {
union {
int i;
@@ -12,6 +17,7 @@ typedef struct foo_struct {
foo_t str;

void *read(void *ptr){
+ int x = str.un.coin.head; // RACE!
int x = str.un.coin.head; // RACE!
int a = 32;
return NULL;