diff options
| author | Steve Naroff <snaroff@apple.com> | 2008-01-13 17:10:08 +0000 |
|---|---|---|
| committer | Steve Naroff <snaroff@apple.com> | 2008-01-13 17:10:08 +0000 |
| commit | 826e91ae04a2e78d6aa61e1e6af8ad615ea60cff (patch) | |
| tree | 2efde9b3ef0acb52b398dc3e57cb04fd3bbc2087 /clang/test/Sema | |
| parent | ff70c5de69c0bf159a711015671815557b6e278d (diff) | |
| download | bcm5719-llvm-826e91ae04a2e78d6aa61e1e6af8ad615ea60cff.tar.gz bcm5719-llvm-826e91ae04a2e78d6aa61e1e6af8ad615ea60cff.zip | |
Change Sema::CheckAddressOfOperation() to respect C99-only addressof rules.
Remove diagnostics from Sema::CheckIndirectionOperand(). C89/C99 allow dereferencing an incomplete type. clang appears to be emulating some incorrect gcc behavior (see below).
void
foo (void)
{
struct b;
struct b* x = 0;
struct b* y = &*x; // gcc produces an error ("dereferencing pointer to incomplete type")
}
With this patch, the above is now allowed.
Bug/Patch by Eli Friedman!
llvm-svn: 45933
Diffstat (limited to 'clang/test/Sema')
| -rw-r--r-- | clang/test/Sema/conditional-expr.c | 2 | ||||
| -rw-r--r-- | clang/test/Sema/deref.c | 22 |
2 files changed, 23 insertions, 1 deletions
diff --git a/clang/test/Sema/conditional-expr.c b/clang/test/Sema/conditional-expr.c index f6b9d1f42da..87fe2d2ed66 100644 --- a/clang/test/Sema/conditional-expr.c +++ b/clang/test/Sema/conditional-expr.c @@ -1,7 +1,7 @@ // RUN: clang -fsyntax-only -verify -pedantic %s void foo() { *(0 ? (double *)0 : (void *)0) = 0; - *((void *) 0) = 0; // -expected-warning {{dereferencing void pointer}} -expected-error {{incomplete type 'void' is not assignable}} + *((void *) 0) = 0; // -expected-error {{incomplete type 'void' is not assignable}} double *dp; int *ip; void *vp; diff --git a/clang/test/Sema/deref.c b/clang/test/Sema/deref.c new file mode 100644 index 00000000000..87f1b4862e5 --- /dev/null +++ b/clang/test/Sema/deref.c @@ -0,0 +1,22 @@ +// RUN: clang -fsyntax-only -verify -std=c90 %s +void +foo (void) +{ + struct b; + struct b* x = 0; + struct b* y = &*x; +} + +void foo2 (void) +{ + typedef int (*arrayptr)[]; + arrayptr x = 0; + arrayptr y = &*x; +} + +void foo3 (void) +{ + void* x = 0; + void* y = &*x; // expected-error {{invalid lvalue in address expression}} +} + |

