summaryrefslogtreecommitdiffstats
path: root/test/ASTMerge
diff options
context:
space:
mode:
Diffstat (limited to 'test/ASTMerge')
-rw-r--r--test/ASTMerge/Inputs/category1.m25
-rw-r--r--test/ASTMerge/Inputs/category2.m27
-rw-r--r--test/ASTMerge/Inputs/exprs1.c10
-rw-r--r--test/ASTMerge/Inputs/exprs2.c10
-rw-r--r--test/ASTMerge/Inputs/interface1.m78
-rw-r--r--test/ASTMerge/Inputs/interface2.m77
-rw-r--r--test/ASTMerge/Inputs/namespace1.cpp17
-rw-r--r--test/ASTMerge/Inputs/namespace2.cpp17
-rw-r--r--test/ASTMerge/Inputs/property1.m12
-rw-r--r--test/ASTMerge/Inputs/property2.m13
-rw-r--r--test/ASTMerge/category.m9
-rw-r--r--test/ASTMerge/exprs.c4
-rw-r--r--test/ASTMerge/interface.m17
-rw-r--r--test/ASTMerge/namespace.cpp6
-rw-r--r--test/ASTMerge/property.m9
15 files changed, 325 insertions, 6 deletions
diff --git a/test/ASTMerge/Inputs/category1.m b/test/ASTMerge/Inputs/category1.m
new file mode 100644
index 0000000..ade1c6c
--- /dev/null
+++ b/test/ASTMerge/Inputs/category1.m
@@ -0,0 +1,25 @@
+@interface I1
+@end
+
+// Matching category
+@interface I1 (Cat1)
+- (int)method0;
+@end
+
+// Matching class extension
+@interface I1 ()
+- (int)method1;
+@end
+
+// Mismatched category
+@interface I1 (Cat2)
+- (int)method2;
+@end
+
+@interface I2
+@end
+
+// Mismatched class extension
+@interface I2 ()
+- (int)method3;
+@end
diff --git a/test/ASTMerge/Inputs/category2.m b/test/ASTMerge/Inputs/category2.m
new file mode 100644
index 0000000..f66c208
--- /dev/null
+++ b/test/ASTMerge/Inputs/category2.m
@@ -0,0 +1,27 @@
+typedef int Int;
+
+@interface I1
+@end
+
+// Matching category
+@interface I1 (Cat1)
+- (Int)method0;
+@end
+
+// Matching class extension
+@interface I1 ()
+- (Int)method1;
+@end
+
+// Mismatched category
+@interface I1 (Cat2)
+- (float)method2;
+@end
+
+@interface I2
+@end
+
+// Mismatched class extension
+@interface I2 ()
+- (float)method3;
+@end
diff --git a/test/ASTMerge/Inputs/exprs1.c b/test/ASTMerge/Inputs/exprs1.c
new file mode 100644
index 0000000..1c268da
--- /dev/null
+++ b/test/ASTMerge/Inputs/exprs1.c
@@ -0,0 +1,10 @@
+// Matching
+enum E0 {
+ E0_Val0 = 'a',
+ E0_Val1 = (17),
+ E0_Val2 = (1 << 2),
+ E0_Val3 = E0_Val2,
+ E0_Val4 = sizeof(int*),
+ E0_Val5 = (unsigned int)-1
+};
+
diff --git a/test/ASTMerge/Inputs/exprs2.c b/test/ASTMerge/Inputs/exprs2.c
new file mode 100644
index 0000000..1c268da
--- /dev/null
+++ b/test/ASTMerge/Inputs/exprs2.c
@@ -0,0 +1,10 @@
+// Matching
+enum E0 {
+ E0_Val0 = 'a',
+ E0_Val1 = (17),
+ E0_Val2 = (1 << 2),
+ E0_Val3 = E0_Val2,
+ E0_Val4 = sizeof(int*),
+ E0_Val5 = (unsigned int)-1
+};
+
diff --git a/test/ASTMerge/Inputs/interface1.m b/test/ASTMerge/Inputs/interface1.m
index 1aa1c3b..7e9935d 100644
--- a/test/ASTMerge/Inputs/interface1.m
+++ b/test/ASTMerge/Inputs/interface1.m
@@ -1,7 +1,81 @@
// Matches
-@interface I1
+@interface I1 {
+ int ivar1;
+}
@end
// Matches
-@interface I2 : I1
+@interface I2 : I1 {
+ float ivar2;
+}
+@end
+
+// Ivar mismatch
+@interface I3 {
+ int ivar1;
+ int ivar2;
+}
+@end
+
+// Superclass mismatch
+@interface I4 : I2 {
+}
+@end
+
+// Methods match
+@interface I5
+- (int)foo;
++ (float)bar;
+@end
+
+// Method mismatch
+@interface I6
+- (int)foo;
++ (int)foo;
+@end
+
+// Method mismatch
+@interface I7
+- (int)foo;
++ (int)bar:(int)x;
+@end
+
+// Method mismatch
+@interface I8
+- (int)foo;
++ (int)bar:(float)x;
+@end
+
+// Matching protocol
+@protocol P0
++ (int)foo;
+- (int)bar:(float)x;
+@end
+
+// Protocol with mismatching method
+@protocol P1
++ (int)foo;
+- (int)bar:(float)x;
+@end
+
+// Interface with protocol
+@interface I9 <P0>
++ (int)foo;
+- (int)bar:(float)x;
+@end
+
+// Protocol with protocol
+@protocol P2 <P0>
+- (float)wibble:(int)a1 second:(int)a2;
+@end
+
+// Forward-declared interfaces
+@class I10, I11;
+@interface I12
+@end
+
+// Forward-declared protocols
+@protocol P3, P5;
+@protocol P4
+- (double)honk:(int)a;
@end
diff --git a/test/ASTMerge/Inputs/interface2.m b/test/ASTMerge/Inputs/interface2.m
index 1aa1c3b..bef7fb8 100644
--- a/test/ASTMerge/Inputs/interface2.m
+++ b/test/ASTMerge/Inputs/interface2.m
@@ -1,7 +1,80 @@
// Matches
-@interface I1
+@interface I1 {
+ int ivar1;
+}
@end
// Matches
-@interface I2 : I1
+@interface I2 : I1 {
+ float ivar2;
+}
+@end
+
+// Ivar mismatch
+@interface I3 {
+ int ivar1;
+ float ivar2;
+}
+@end
+
+// Superclass mismatch
+@interface I4 : I1 {
+}
+@end
+
+// Methods match
+@interface I5
++ (float)bar;
+- (int)foo;
+@end
+
+// Method mismatch
+@interface I6
++ (float)foo;
+@end
+
+// Method mismatch
+@interface I7
+- (int)foo;
++ (int)bar:(float)x;
+@end
+
+// Method mismatch
+@interface I8
+- (int)foo;
++ (int)bar:(float)x, ...;
+@end
+
+// Matching protocol
+@protocol P0
++ (int)foo;
+- (int)bar:(float)x;
+@end
+
+// Protocol with mismatching method
+@protocol P1
++ (int)foo;
+- (int)bar:(double)x;
+@end
+
+// Interface with protocol
+@interface I9 <P0>
++ (int)foo;
+- (int)bar:(float)x;
+@end
+
+// Protocol with protocol
+@protocol P2 <P0>
+- (float)wibble:(int)a1 second:(int)a2;
+@end
+
+// Forward-declared interface
+@class I12, I10;
+@interface I11
+@end
+
+// Forward-declared protocols
+@protocol P3, P4;
+@protocol P5
+- (double)honk:(int)a;
@end
diff --git a/test/ASTMerge/Inputs/namespace1.cpp b/test/ASTMerge/Inputs/namespace1.cpp
new file mode 100644
index 0000000..1ff84f31
--- /dev/null
+++ b/test/ASTMerge/Inputs/namespace1.cpp
@@ -0,0 +1,17 @@
+// Merge success
+namespace N1 {
+ int x;
+}
+
+// Merge multiple namespaces
+namespace N2 {
+ extern int x;
+}
+namespace N2 {
+ extern float y;
+}
+
+// Merge namespace with conflict
+namespace N3 {
+ extern float z;
+}
diff --git a/test/ASTMerge/Inputs/namespace2.cpp b/test/ASTMerge/Inputs/namespace2.cpp
new file mode 100644
index 0000000..80429f7
--- /dev/null
+++ b/test/ASTMerge/Inputs/namespace2.cpp
@@ -0,0 +1,17 @@
+// Merge success
+namespace N1 {
+ extern int x0;
+}
+
+// Merge multiple namespaces
+namespace N2 {
+ extern int x;
+}
+namespace N2 {
+ extern float y;
+}
+
+// Merge namespace with conflict
+namespace N3 {
+ extern double z;
+}
diff --git a/test/ASTMerge/Inputs/property1.m b/test/ASTMerge/Inputs/property1.m
new file mode 100644
index 0000000..37887a3
--- /dev/null
+++ b/test/ASTMerge/Inputs/property1.m
@@ -0,0 +1,12 @@
+// Matching properties
+@interface I1 {
+}
+- (int)getProp2;
+- (void)setProp2:(int)value;
+@end
+
+// Mismatched property
+@interface I2
+@property (readonly) float Prop1;
+@end
+
diff --git a/test/ASTMerge/Inputs/property2.m b/test/ASTMerge/Inputs/property2.m
new file mode 100644
index 0000000..6039f10
--- /dev/null
+++ b/test/ASTMerge/Inputs/property2.m
@@ -0,0 +1,13 @@
+// Matching properties
+@interface I1 {
+}
+- (int)getProp2;
+- (void)setProp2:(int)value;
+@property (readonly) int Prop1;
+@property (getter = getProp2, setter = setProp2:) int Prop2;
+@end
+
+// Mismatched property
+@interface I2
+@property (readonly) int Prop1;
+@end
diff --git a/test/ASTMerge/category.m b/test/ASTMerge/category.m
new file mode 100644
index 0000000..bf0d11b
--- /dev/null
+++ b/test/ASTMerge/category.m
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -emit-pch -o %t.1.ast %S/Inputs/category1.m
+// RUN: %clang_cc1 -emit-pch -o %t.2.ast %S/Inputs/category2.m
+// RUN: %clang_cc1 -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only %s 2>&1 | FileCheck %s
+
+// CHECK: category2.m:18:1: error: instance method 'method2' has incompatible result types in different translation units ('float' vs. 'int')
+// CHECK: category1.m:16:1: note: instance method 'method2' also declared here
+// CHECK: category2.m:26:1: error: instance method 'method3' has incompatible result types in different translation units ('float' vs. 'int')
+// CHECK: category1.m:24:1: note: instance method 'method3' also declared here
+// CHECK: 4 diagnostics generated.
diff --git a/test/ASTMerge/exprs.c b/test/ASTMerge/exprs.c
new file mode 100644
index 0000000..0a4e1e5
--- /dev/null
+++ b/test/ASTMerge/exprs.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -emit-pch -o %t.1.ast %S/Inputs/exprs1.c
+// RUN: %clang_cc1 -emit-pch -o %t.2.ast %S/Inputs/exprs2.c
+// RUN: %clang_cc1 -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only -verify %s
+
diff --git a/test/ASTMerge/interface.m b/test/ASTMerge/interface.m
index d6af2f4..47e4e05 100644
--- a/test/ASTMerge/interface.m
+++ b/test/ASTMerge/interface.m
@@ -1,6 +1,19 @@
// 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
+// RUN: %clang_cc1 -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only %s 2>&1 | FileCheck %s
-// FIXME: FileCheck!
+// CHECK: interface2.m:16:9: error: instance variable 'ivar2' declared with incompatible types in different translation units ('float' vs. 'int')
+// CHECK: interface1.m:16:7: note: declared here with type 'int'
+// CHECK: interface1.m:21:1: error: class 'I4' has incompatible superclasses
+// CHECK: interface1.m:21:17: note: inherits from superclass 'I2' here
+// CHECK: interface2.m:21:17: note: inherits from superclass 'I1' here
+// CHECK: interface2.m:33:1: error: class method 'foo' has incompatible result types in different translation units ('float' vs. 'int')
+// CHECK: interface1.m:34:1: note: class method 'foo' also declared here
+// CHECK: interface2.m:39:19: error: class method 'bar:' has a parameter with a different types in different translation units ('float' vs. 'int')
+// CHECK: interface1.m:40:17: note: declared here with type 'int'
+// CHECK: interface2.m:45:1: error: class method 'bar:' is variadic in one translation unit and not variadic in another
+// CHECK: interface1.m:46:1: note: class method 'bar:' also declared here
+// CHECK: interface2.m:57:20: error: instance method 'bar:' has a parameter with a different types in different translation units ('double' vs. 'float')
+// CHECK: interface1.m:58:19: note: declared here with type 'float'
+// CHECK: 13 diagnostics generated
diff --git a/test/ASTMerge/namespace.cpp b/test/ASTMerge/namespace.cpp
new file mode 100644
index 0000000..6c46f0a
--- /dev/null
+++ b/test/ASTMerge/namespace.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -emit-pch -o %t.1.ast %S/Inputs/namespace1.cpp
+// RUN: %clang_cc1 -emit-pch -o %t.2.ast %S/Inputs/namespace2.cpp
+// RUN: %clang_cc1 -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only %s 2>&1 | FileCheck %s
+
+// CHECK: namespace2.cpp:16:17: error: external variable 'z' declared with incompatible types in different translation units ('double' vs. 'float')
+// CHECK: namespace1.cpp:16:16: note: declared here with type 'float'
diff --git a/test/ASTMerge/property.m b/test/ASTMerge/property.m
new file mode 100644
index 0000000..0fd7e48
--- /dev/null
+++ b/test/ASTMerge/property.m
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -emit-pch -o %t.1.ast %S/Inputs/property1.m
+// RUN: %clang_cc1 -emit-pch -o %t.2.ast %S/Inputs/property2.m
+// RUN: %clang_cc1 -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only %s 2>&1 | FileCheck %s
+
+// CHECK: property2.m:12:26: error: property 'Prop1' declared with incompatible types in different translation units ('int' vs. 'float')
+// CHECK: property1.m:10:28: note: declared here with type 'float'
+// CHECK: property2.m:12:26: error: instance method 'Prop1' has incompatible result types in different translation units ('int' vs. 'float')
+// CHECK: property1.m:10:28: note: instance method 'Prop1' also declared here
+// CHECK: 4 diagnostics generated.
OpenPOWER on IntegriCloud