Fix Sema::CheckConditionalOperands(). The null pointer constant checks need to precede the check for two pointer operands.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45732 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/Sema/conditional-expr.c b/test/Sema/conditional-expr.c
new file mode 100644
index 0000000..f6b9d1f
--- /dev/null
+++ b/test/Sema/conditional-expr.c
@@ -0,0 +1,17 @@
+// 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}}
+ double *dp;
+ int *ip;
+ void *vp;
+
+ dp = vp;
+ vp = dp;
+ ip = dp; // -expected-warning {{incompatible pointer types assigning 'double *', expected 'int *'}}
+ dp = ip; // -expected-warning {{incompatible pointer types assigning 'int *', expected 'double *'}}
+ dp = 0 ? (double *)0 : (void *)0;
+ vp = 0 ? (double *)0 : (void *)0;
+ ip = 0 ? (double *)0 : (void *)0; // -expected-warning {{incompatible pointer types assigning 'double *', expected 'int *'}}
+}
+