diff options
| author | Peter Collingbourne <peter@pcc.me.uk> | 2010-10-24 18:30:18 +0000 |
|---|---|---|
| committer | Peter Collingbourne <peter@pcc.me.uk> | 2010-10-24 18:30:18 +0000 |
| commit | a99fdcf93ef8a1f55a5e7da6aca1a72444ac4838 (patch) | |
| tree | 78c3fc747b82496f5e515f1f6c1374408a396374 /clang/test | |
| parent | 800fd3533c2c862c88bcfd86694e2fd9875c461f (diff) | |
| download | bcm5719-llvm-a99fdcf93ef8a1f55a5e7da6aca1a72444ac4838.tar.gz bcm5719-llvm-a99fdcf93ef8a1f55a5e7da6aca1a72444ac4838.zip | |
Implement GNU C extension: two types are compatible if they appear
as a function argument, one of the types is a transparent union type
and the other type is compatible with a union member
llvm-svn: 117243
Diffstat (limited to 'clang/test')
| -rw-r--r-- | clang/test/CodeGen/transparent-union.c | 5 | ||||
| -rw-r--r-- | clang/test/Sema/transparent-union.c | 18 |
2 files changed, 22 insertions, 1 deletions
diff --git a/clang/test/CodeGen/transparent-union.c b/clang/test/CodeGen/transparent-union.c index 9f1cdda18d1..0bdbd577f90 100644 --- a/clang/test/CodeGen/transparent-union.c +++ b/clang/test/CodeGen/transparent-union.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm -o %t %s +// RUN: %clang_cc1 -Werror -triple i386-unknown-unknown -emit-llvm -o %t %s // RUN: FileCheck < %t %s // // FIXME: Note that we don't currently get the ABI right here. f0() should be @@ -12,9 +12,12 @@ void f0(transp_t0 obj); // CHECK: define void @f1_0(i32* %a0) // CHECK: call void @f0(%union.anon* byval %{{.*}}) +// CHECK: call void %{{.*}}(i8* %{{[a-z0-9]*}}) // CHECK: } void f1_0(int *a0) { + void (*f0p)(void *) = f0; f0(a0); + f0p(a0); } void f1_1(int *a0) { diff --git a/clang/test/Sema/transparent-union.c b/clang/test/Sema/transparent-union.c index 27d5c2403b4..d13b4045a91 100644 --- a/clang/test/Sema/transparent-union.c +++ b/clang/test/Sema/transparent-union.c @@ -17,6 +17,24 @@ void g(int *ip, float *fp, char *cp) { tu.ip = ip; } +/* Test ability to redeclare a function taking a transparent_union arg + with various compatible and incompatible argument types. */ + +void fip(TU); +void fip(int *i) {} + +void ffp(TU); +void ffp(float *f) {} + +void fvp(TU); // expected-note{{previous declaration is here}} +void fvp(void *p) {} // expected-error{{conflicting types}} + +void fsp(TU); // expected-note{{previous declaration is here}} +void fsp(short *s) {} // expected-error{{conflicting types}} + +void fi(TU); // expected-note{{previous declaration is here}} +void fi(int i) {} // expected-error{{conflicting types}} + /* FIXME: we'd like to just use an "int" here and align it differently from the normal "int", but if we do so we lose the alignment information from the typedef within the compiler. */ |

