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!



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45933 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/Sema/deref.c b/test/Sema/deref.c
new file mode 100644
index 0000000..87f1b48
--- /dev/null
+++ b/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}}
+}
+