aboutsummaryrefslogtreecommitdiff
path: root/test/ASTMerge
diff options
context:
space:
mode:
Diffstat (limited to 'test/ASTMerge')
-rw-r--r--test/ASTMerge/Inputs/enum1.c42
-rw-r--r--test/ASTMerge/Inputs/enum2.c42
-rw-r--r--test/ASTMerge/Inputs/function1.c6
-rw-r--r--test/ASTMerge/Inputs/function2.c7
-rw-r--r--test/ASTMerge/Inputs/interface1.m7
-rw-r--r--test/ASTMerge/Inputs/interface2.m7
-rw-r--r--test/ASTMerge/Inputs/lit.local.cfg1
-rw-r--r--test/ASTMerge/Inputs/struct1.c63
-rw-r--r--test/ASTMerge/Inputs/struct2.c60
-rw-r--r--test/ASTMerge/Inputs/typedef1.c4
-rw-r--r--test/ASTMerge/Inputs/typedef2.c4
-rw-r--r--test/ASTMerge/Inputs/var1.c7
-rw-r--r--test/ASTMerge/Inputs/var1.h1
-rw-r--r--test/ASTMerge/Inputs/var2.c7
-rw-r--r--test/ASTMerge/enum.c25
-rw-r--r--test/ASTMerge/function.c9
-rw-r--r--test/ASTMerge/interface.m6
-rw-r--r--test/ASTMerge/struct.c42
-rw-r--r--test/ASTMerge/typedef.c7
-rw-r--r--test/ASTMerge/var.c12
20 files changed, 359 insertions, 0 deletions
diff --git a/test/ASTMerge/Inputs/enum1.c b/test/ASTMerge/Inputs/enum1.c
new file mode 100644
index 000000000000..f2b9c5c98fde
--- /dev/null
+++ b/test/ASTMerge/Inputs/enum1.c
@@ -0,0 +1,42 @@
+// Matching
+enum E1 {
+ E1Enumerator1,
+ E1Enumerator2 = 3,
+ E1Enumerator3
+} x1;
+
+// Value mismatch
+enum E2 {
+ E2Enumerator1,
+ E2Enumerator2 = 3,
+ E2Enumerator3
+} x2;
+
+// Name mismatch
+enum E3 {
+ E3Enumerator1,
+ E3Enumerator2 = 3,
+ E3Enumerator3
+} x3;
+
+// Missing enumerator
+enum E4 {
+ E4Enumerator1,
+ E4Enumerator2,
+ E4Enumerator3
+} x4;
+
+// Extra enumerator
+enum E5 {
+ E5Enumerator1,
+ E5Enumerator2,
+ E5Enumerator3
+} x5;
+
+// Matching, with typedef
+typedef enum {
+ E6Enumerator1,
+ E6Enumerator2
+} E6;
+
+E6 x6;
diff --git a/test/ASTMerge/Inputs/enum2.c b/test/ASTMerge/Inputs/enum2.c
new file mode 100644
index 000000000000..315b4dcb6ef5
--- /dev/null
+++ b/test/ASTMerge/Inputs/enum2.c
@@ -0,0 +1,42 @@
+// Matching
+enum E1 {
+ E1Enumerator1,
+ E1Enumerator2 = 3,
+ E1Enumerator3
+} x1;
+
+// Value mismatch
+enum E2 {
+ E2Enumerator1,
+ E2Enumerator2 = 4,
+ E2Enumerator3
+} x2;
+
+// Name mismatch
+enum E3 {
+ E3Enumerator1,
+ E3Enumerator = 3,
+ E3Enumerator3
+} x3;
+
+// Missing enumerator
+enum E4 {
+ E4Enumerator1,
+ E4Enumerator2
+} x4;
+
+// Extra enumerator
+enum E5 {
+ E5Enumerator1,
+ E5Enumerator2,
+ E5Enumerator3,
+ E5Enumerator4
+} x5;
+
+// Matching, with typedef
+typedef enum {
+ E6Enumerator1,
+ E6Enumerator2
+} E6;
+
+E6 x6;
diff --git a/test/ASTMerge/Inputs/function1.c b/test/ASTMerge/Inputs/function1.c
new file mode 100644
index 000000000000..4523bd3d79bf
--- /dev/null
+++ b/test/ASTMerge/Inputs/function1.c
@@ -0,0 +1,6 @@
+void f0(int);
+void f1(int, float);
+void f2();
+void f3(void);
+void f4(int, int);
+int f5(int) __attribute__((const));
diff --git a/test/ASTMerge/Inputs/function2.c b/test/ASTMerge/Inputs/function2.c
new file mode 100644
index 000000000000..6ca810a6f20b
--- /dev/null
+++ b/test/ASTMerge/Inputs/function2.c
@@ -0,0 +1,7 @@
+typedef int Int;
+void f0(Int);
+void f1(Int, double);
+void f2(int, int);
+void f3(int);
+static void f4(float, float);
+int f5(int) __attribute__((const));
diff --git a/test/ASTMerge/Inputs/interface1.m b/test/ASTMerge/Inputs/interface1.m
new file mode 100644
index 000000000000..1aa1c3b89413
--- /dev/null
+++ b/test/ASTMerge/Inputs/interface1.m
@@ -0,0 +1,7 @@
+// Matches
+@interface I1
+@end
+
+// Matches
+@interface I2 : I1
+@end
diff --git a/test/ASTMerge/Inputs/interface2.m b/test/ASTMerge/Inputs/interface2.m
new file mode 100644
index 000000000000..1aa1c3b89413
--- /dev/null
+++ b/test/ASTMerge/Inputs/interface2.m
@@ -0,0 +1,7 @@
+// Matches
+@interface I1
+@end
+
+// Matches
+@interface I2 : I1
+@end
diff --git a/test/ASTMerge/Inputs/lit.local.cfg b/test/ASTMerge/Inputs/lit.local.cfg
new file mode 100644
index 000000000000..e6f55eef7af5
--- /dev/null
+++ b/test/ASTMerge/Inputs/lit.local.cfg
@@ -0,0 +1 @@
+config.suffixes = []
diff --git a/test/ASTMerge/Inputs/struct1.c b/test/ASTMerge/Inputs/struct1.c
new file mode 100644
index 000000000000..af2af8abc42a
--- /dev/null
+++ b/test/ASTMerge/Inputs/struct1.c
@@ -0,0 +1,63 @@
+typedef int Int;
+typedef float Float;
+
+// Matches
+struct S0 {
+ Int field1;
+ Float field2;
+};
+
+struct S0 x0;
+
+// Mismatch in field type
+struct S1 {
+ Int field1;
+ int field2;
+};
+
+struct S1 x1;
+
+// Mismatch in tag kind.
+struct S2 { int i; float f; } x2;
+
+// Missing fields
+struct S3 { int i; float f; double d; } x3;
+
+// Extra fields
+struct S4 { int i; } x4;
+
+// Bit-field matches
+struct S5 { int i : 8; unsigned j : 8; } x5;
+
+// Bit-field mismatch
+struct S6 { int i : 8; unsigned j : 8; } x6;
+
+// Bit-field mismatch
+struct S7 { int i : 8; unsigned j : 8; } x7;
+
+// Incomplete type
+struct S8 *x8;
+
+// Incomplete type
+struct S9 { int i; float f; } *x9;
+
+// Incomplete type
+struct S10 *x10;
+
+// Matches
+struct ListNode {
+ int value;
+ struct ListNode *Next;
+} xList;
+
+// Mismatch due to struct used internally
+struct DeepError {
+ int value;
+ struct DeeperError { int i; int f; } *Deeper;
+} xDeep;
+
+// Matches
+struct {
+ Int i;
+ float f;
+} x11;
diff --git a/test/ASTMerge/Inputs/struct2.c b/test/ASTMerge/Inputs/struct2.c
new file mode 100644
index 000000000000..4b43df71d8d6
--- /dev/null
+++ b/test/ASTMerge/Inputs/struct2.c
@@ -0,0 +1,60 @@
+// Matches
+struct S0 {
+ int field1;
+ float field2;
+};
+
+struct S0 x0;
+
+// Mismatch in field type
+struct S1 {
+ int field1;
+ float field2;
+};
+
+struct S1 x1;
+
+// Mismatch in tag kind.
+union S2 { int i; float f; } x2;
+
+// Missing fields
+struct S3 { int i; float f; } x3;
+
+// Extra fields
+struct S4 { int i; float f; } x4;
+
+// Bit-field matches
+struct S5 { int i : 8; unsigned j : 8; } x5;
+
+// Bit-field mismatch
+struct S6 { int i : 8; unsigned j; } x6;
+
+// Bit-field mismatch
+struct S7 { int i : 8; unsigned j : 16; } x7;
+
+// Incomplete type
+struct S8 { int i; float f; } *x8;
+
+// Incomplete type
+struct S9 *x9;
+
+// Incomplete type
+struct S10 *x10;
+
+// Matches
+struct ListNode {
+ int value;
+ struct ListNode *Next;
+} xList;
+
+// Mismatch due to struct used internally
+struct DeepError {
+ int value;
+ struct DeeperError { int i; float f; } *Deeper;
+} xDeep;
+
+// Matches
+struct {
+ int i;
+ float f;
+} x11;
diff --git a/test/ASTMerge/Inputs/typedef1.c b/test/ASTMerge/Inputs/typedef1.c
new file mode 100644
index 000000000000..56576756856d
--- /dev/null
+++ b/test/ASTMerge/Inputs/typedef1.c
@@ -0,0 +1,4 @@
+typedef int Typedef1;
+typedef int Typedef2;
+Typedef1 x1;
+Typedef2 x2;
diff --git a/test/ASTMerge/Inputs/typedef2.c b/test/ASTMerge/Inputs/typedef2.c
new file mode 100644
index 000000000000..129d7101e91e
--- /dev/null
+++ b/test/ASTMerge/Inputs/typedef2.c
@@ -0,0 +1,4 @@
+typedef int Typedef1;
+typedef double Typedef2;
+Typedef1 x1;
+Typedef2 x2;
diff --git a/test/ASTMerge/Inputs/var1.c b/test/ASTMerge/Inputs/var1.c
new file mode 100644
index 000000000000..4f5cbe16ab6c
--- /dev/null
+++ b/test/ASTMerge/Inputs/var1.c
@@ -0,0 +1,7 @@
+int *x0;
+float **x1;
+#include "var1.h"
+int xarray0[17];
+int xarray1[];
+int xarray2[18];
+int xarray3[18];
diff --git a/test/ASTMerge/Inputs/var1.h b/test/ASTMerge/Inputs/var1.h
new file mode 100644
index 000000000000..1518e17ef0c8
--- /dev/null
+++ b/test/ASTMerge/Inputs/var1.h
@@ -0,0 +1 @@
+double x2;
diff --git a/test/ASTMerge/Inputs/var2.c b/test/ASTMerge/Inputs/var2.c
new file mode 100644
index 000000000000..01986e4208ca
--- /dev/null
+++ b/test/ASTMerge/Inputs/var2.c
@@ -0,0 +1,7 @@
+int *x0;
+double *x1;
+int x2;
+int xarray0[17];
+int xarray1[17];
+int xarray2[];
+int xarray3[17];
diff --git a/test/ASTMerge/enum.c b/test/ASTMerge/enum.c
new file mode 100644
index 000000000000..9b78fd1022e4
--- /dev/null
+++ b/test/ASTMerge/enum.c
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -emit-pch -o %t.1.ast %S/Inputs/enum1.c
+// RUN: %clang_cc1 -emit-pch -o %t.2.ast %S/Inputs/enum2.c
+// RUN: %clang_cc1 -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only %s 2>&1 | FileCheck %s
+
+// CHECK: enum1.c:9:6: warning: type 'enum E2' has incompatible definitions in different translation units
+// CHECK: enum1.c:11:3: note: enumerator 'E2Enumerator2' with value 3 here
+// CHECK: enum2.c:11:3: note: enumerator 'E2Enumerator2' with value 4 here
+// CHECK: enum2.c:13:3: error: external variable 'x2' declared with incompatible types in different translation units ('enum E2' vs. 'enum E2')
+// CHECK: enum1.c:13:3: note: declared here with type 'enum E2'
+// CHECK: enum1.c:16:6: warning: type 'enum E3' has incompatible definitions in different translation units
+// CHECK: enum1.c:18:3: note: enumerator 'E3Enumerator2' with value 3 here
+// CHECK: enum2.c:18:3: note: enumerator 'E3Enumerator' with value 3 here
+// CHECK: enum2.c:20:3: error: external variable 'x3' declared with incompatible types in different translation units ('enum E3' vs. 'enum E3')
+// CHECK: enum1.c:20:3: note: declared here with type 'enum E3'
+// CHECK: enum1.c:23:6: warning: type 'enum E4' has incompatible definitions in different translation units
+// CHECK: enum1.c:26:3: note: enumerator 'E4Enumerator3' with value 2 here
+// CHECK: enum2.c:23:6: note: no corresponding enumerator here
+// CHECK: enum2.c:26:3: error: external variable 'x4' declared with incompatible types in different translation units ('enum E4' vs. 'enum E4')
+// CHECK: enum1.c:27:3: note: declared here with type 'enum E4'
+// CHECK: enum1.c:30:6: warning: type 'enum E5' has incompatible definitions in different translation units
+// CHECK: enum2.c:33:3: note: enumerator 'E5Enumerator4' with value 3 here
+// CHECK: enum1.c:30:6: note: no corresponding enumerator here
+// CHECK: enum2.c:34:3: error: external variable 'x5' declared with incompatible types in different translation units ('enum E5' vs. 'enum E5')
+// CHECK: enum1.c:34:3: note: declared here with type 'enum E5'
+// CHECK: 20 diagnostics generated
diff --git a/test/ASTMerge/function.c b/test/ASTMerge/function.c
new file mode 100644
index 000000000000..581b6ec5882c
--- /dev/null
+++ b/test/ASTMerge/function.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -emit-pch -o %t.1.ast %S/Inputs/function1.c
+// RUN: %clang_cc1 -emit-pch -o %t.2.ast %S/Inputs/function2.c
+// RUN: %clang_cc1 -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only %s 2>&1 | FileCheck %s
+
+// CHECK: function2.c:3:6: error: external function 'f1' declared with incompatible types in different translation units ('void (Int, double)' vs. 'void (int, float)')
+// CHECK: function1.c:2:6: note: declared here with type 'void (int, float)'
+// CHECK: function2.c:5:6: error: external function 'f3' declared with incompatible types in different translation units ('void (int)' vs. 'void (void)')
+// CHECK: function1.c:4:6: note: declared here with type 'void (void)'
+// CHECK: 4 diagnostics generated
diff --git a/test/ASTMerge/interface.m b/test/ASTMerge/interface.m
new file mode 100644
index 000000000000..d6af2f4b1665
--- /dev/null
+++ b/test/ASTMerge/interface.m
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -emit-pch -o %t.1.ast %S/Inputs/interface1.m
+// RUN: %clang_cc1 -emit-pch -o %t.2.ast %S/Inputs/interface2.m
+// RUN: %clang_cc1 -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only %s 2>&1
+
+// FIXME: FileCheck!
+
diff --git a/test/ASTMerge/struct.c b/test/ASTMerge/struct.c
new file mode 100644
index 000000000000..e72b93b249f9
--- /dev/null
+++ b/test/ASTMerge/struct.c
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -emit-pch -o %t.1.ast %S/Inputs/struct1.c
+// RUN: %clang_cc1 -emit-pch -o %t.2.ast %S/Inputs/struct2.c
+// RUN: %clang_cc1 -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only %s 2>&1 | FileCheck %s
+
+// CHECK: struct1.c:13:8: warning: type 'struct S1' has incompatible definitions in different translation units
+// CHECK: struct1.c:15:7: note: field 'field2' has type 'int' here
+// CHECK: struct2.c:12:9: note: field 'field2' has type 'float' here
+// CHECK: struct2.c:15:11: error: external variable 'x1' declared with incompatible types in different translation units ('struct S1' vs. 'struct S1')
+// CHECK: struct1.c:18:11: note: declared here with type 'struct S1'
+// CHECK: struct1.c:21:8: warning: type 'struct S2' has incompatible definitions in different translation units
+// CHECK: struct2.c:18:7: note: 'S2' is a union here
+// CHECK: struct2.c:18:30: error: external variable 'x2' declared with incompatible types in different translation units ('union S2' vs. 'struct S2')
+// CHECK: struct1.c:21:31: note: declared here with type 'struct S2'
+// CHECK: struct1.c:24:8: warning: type 'struct S3' has incompatible definitions in different translation units
+// CHECK: struct1.c:24:36: note: field 'd' has type 'double' here
+// CHECK: struct2.c:21:8: note: no corresponding field here
+// CHECK: struct2.c:21:31: error: external variable 'x3' declared with incompatible types in different translation units ('struct S3' vs. 'struct S3')
+// CHECK: struct1.c:24:41: note: declared here with type 'struct S3'
+// CHECK: struct1.c:27:8: warning: type 'struct S4' has incompatible definitions in different translation units
+// CHECK: struct2.c:24:26: note: field 'f' has type 'float' here
+// CHECK: struct1.c:27:8: note: no corresponding field here
+// CHECK: struct2.c:24:31: error: external variable 'x4' declared with incompatible types in different translation units ('struct S4' vs. 'struct S4')
+// CHECK: struct1.c:27:22: note: declared here with type 'struct S4'
+// CHECK: struct1.c:33:8: warning: type 'struct S6' has incompatible definitions in different translation units
+// CHECK: struct1.c:33:33: note: bit-field 'j' with type 'unsigned int' and length 8 here
+// CHECK: struct2.c:30:33: note: field 'j' is not a bit-field
+// CHECK: struct2.c:30:38: error: external variable 'x6' declared with incompatible types in different translation units ('struct S6' vs. 'struct S6')
+// CHECK: struct1.c:33:42: note: declared here with type 'struct S6'
+// CHECK: struct1.c:36:8: warning: type 'struct S7' has incompatible definitions in different translation units
+// CHECK: struct1.c:36:33: note: bit-field 'j' with type 'unsigned int' and length 8 here
+// CHECK: struct2.c:33:33: note: bit-field 'j' with type 'unsigned int' and length 16 here
+// CHECK: struct2.c:33:43: error: external variable 'x7' declared with incompatible types in different translation units ('struct S7' vs. 'struct S7')
+// CHECK: struct1.c:36:42: note: declared here with type 'struct S7'
+// CHECK: struct1.c:56:10: warning: type 'struct DeeperError' has incompatible definitions in different translation units
+// CHECK: struct1.c:56:35: note: field 'f' has type 'int' here
+// CHECK: struct2.c:53:37: note: field 'f' has type 'float' here
+// CHECK: struct1.c:54:8: warning: type 'struct DeepError' has incompatible definitions in different translation units
+// CHECK: struct1.c:56:41: note: field 'Deeper' has type 'struct DeeperError *' here
+// CHECK: struct2.c:53:43: note: field 'Deeper' has type 'struct DeeperError *' here
+// CHECK: struct2.c:54:3: error: external variable 'xDeep' declared with incompatible types in different translation units ('struct DeepError' vs. 'struct DeepError')
+// CHECK: struct1.c:57:3: note: declared here with type 'struct DeepError'
+// CHECK: 37 diagnostics
diff --git a/test/ASTMerge/typedef.c b/test/ASTMerge/typedef.c
new file mode 100644
index 000000000000..4498864b4908
--- /dev/null
+++ b/test/ASTMerge/typedef.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -emit-pch -o %t.1.ast %S/Inputs/typedef1.c
+// RUN: %clang_cc1 -emit-pch -o %t.2.ast %S/Inputs/typedef2.c
+// RUN: %clang_cc1 -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only %s 2>&1 | FileCheck %s
+
+// CHECK: typedef2.c:4:10: error: external variable 'x2' declared with incompatible types in different translation units ('Typedef2' (aka 'double') vs. 'Typedef2' (aka 'int'))
+// CHECK: typedef1.c:4:10: note: declared here with type 'Typedef2' (aka 'int')
+// CHECK: 2 diagnostics
diff --git a/test/ASTMerge/var.c b/test/ASTMerge/var.c
new file mode 100644
index 000000000000..fd307940aff7
--- /dev/null
+++ b/test/ASTMerge/var.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -emit-pch -o %t.1.ast %S/Inputs/var1.c
+// RUN: %clang_cc1 -emit-pch -o %t.2.ast %S/Inputs/var2.c
+// RUN: %clang_cc1 -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only %s 2>&1 | FileCheck %s
+
+// CHECK: var2.c:2:9: error: external variable 'x1' declared with incompatible types in different translation units ('double *' vs. 'float **')
+// CHECK: var1.c:2:9: note: declared here with type 'float **'
+// CHECK: var2.c:3:5: error: external variable 'x2' declared with incompatible types in different translation units ('int' vs. 'double')
+// CHECK: In file included from{{.*}}var1.c:3:
+// CHECK: var1.h:1:8: note: declared here with type 'double'
+// CHECK: error: external variable 'xarray3' declared with incompatible types in different translation units ('int [17]' vs. 'int [18]')
+// CHECK: var1.c:7:5: note: declared here with type 'int [18]'
+// CHECK: 6 diagnostics