diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/ASTMerge/Inputs/struct1.c | 20 | ||||
-rw-r--r-- | test/ASTMerge/Inputs/struct2.c | 20 | ||||
-rw-r--r-- | test/ASTMerge/struct.c | 33 |
3 files changed, 70 insertions, 3 deletions
diff --git a/test/ASTMerge/Inputs/struct1.c b/test/ASTMerge/Inputs/struct1.c index 381f00a0a6..5743fe0f48 100644 --- a/test/ASTMerge/Inputs/struct1.c +++ b/test/ASTMerge/Inputs/struct1.c @@ -1,6 +1,7 @@ typedef int Int; typedef float Float; +// Matches struct S0 { Int field1; Float field2; @@ -8,9 +9,28 @@ struct S0 { 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; diff --git a/test/ASTMerge/Inputs/struct2.c b/test/ASTMerge/Inputs/struct2.c index 0a90609006..a707ed2a5b 100644 --- a/test/ASTMerge/Inputs/struct2.c +++ b/test/ASTMerge/Inputs/struct2.c @@ -1,3 +1,4 @@ +// Matches struct S0 { int field1; float field2; @@ -5,9 +6,28 @@ struct S0 { 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; diff --git a/test/ASTMerge/struct.c b/test/ASTMerge/struct.c index 99fa74b10d..c6e57185ab 100644 --- a/test/ASTMerge/struct.c +++ b/test/ASTMerge/struct.c @@ -2,6 +2,33 @@ // 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: struct2.c:13:11: error: external variable 'x1' declared with incompatible types in different translation units ('struct S1' vs. 'struct S1') -// CHECK: struct1.c:16:11: note: declared here with type 'struct S1' -// CHECK: 2 diagnostics +// 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: 29 diagnostics |