aboutsummaryrefslogtreecommitdiff
path: root/test/Sema/conditional-expr.c
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2011-02-18 23:54:50 +0000
committerChandler Carruth <chandlerc@gmail.com>2011-02-18 23:54:50 +0000
commit82214a80c0163e01e4d8dec1426023c89277dbb4 (patch)
treea37aed12f142a232ee5d2b1d3a8f4ec5e409175c /test/Sema/conditional-expr.c
parent0656e5b9aa52f2a90fb38517e504b4eebbe53381 (diff)
Initial steps to improve diagnostics when there is a NULL and
a non-pointer on the two sides of a conditional expression. Patch by Stephen Hines and Mihai Rusu. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125995 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Sema/conditional-expr.c')
-rw-r--r--test/Sema/conditional-expr.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/test/Sema/conditional-expr.c b/test/Sema/conditional-expr.c
index 6e248bc3cf..7a8c9e9f36 100644
--- a/test/Sema/conditional-expr.c
+++ b/test/Sema/conditional-expr.c
@@ -75,3 +75,16 @@ int f2(int x) {
// We can suppress this because the immediate context wants an int.
return (x != 0) ? 0U : x;
}
+
+#define NULL (void*)0
+
+void PR9236() {
+ struct A {int i;} A1;
+ (void)(1 ? A1 : NULL); // expected-error{{non-pointer operand type 'struct A' incompatible with NULL}}
+ (void)(1 ? NULL : A1); // expected-error{{non-pointer operand type 'struct A' incompatible with NULL}}
+ (void)(1 ? 0 : A1); // expected-error{{incompatible operand types}}
+ (void)(1 ? (void*)0 : A1); // expected-error{{incompatible operand types}}
+ (void)(1 ? A1: (void*)0); // expected-error{{incompatible operand types}}
+ (void)(1 ? A1 : (NULL)); // expected-error{{non-pointer operand type 'struct A' incompatible with NULL}}
+}
+