summaryrefslogtreecommitdiffstats
path: root/clang/test/Parser/pointer_promotion.c
diff options
context:
space:
mode:
authorSteve Naroff <snaroff@apple.com>2007-08-16 21:48:38 +0000
committerSteve Naroff <snaroff@apple.com>2007-08-16 21:48:38 +0000
commitcdee44c12a3f5a381eeb06e5ac0c65f1dfe273aa (patch)
treef8f9ebae1a5cd29d28030270fe9db84b8cb0a05a /clang/test/Parser/pointer_promotion.c
parent5f208bea912ff362e699d87240dfb0eb1c244501 (diff)
downloadbcm5719-llvm-cdee44c12a3f5a381eeb06e5ac0c65f1dfe273aa.tar.gz
bcm5719-llvm-cdee44c12a3f5a381eeb06e5ac0c65f1dfe273aa.zip
Fixed Sema::CheckEqualityOperands() and Sema::CheckRelationalOperands() to deal more
thoughtfully with incompatible pointers. This includes: - Emit a diagnostic when two pointers aren't compatible! - Promote one of the pointers/integers so we maintain the invariant expected by the code generator (i.e. that the left/right types match). - Upgrade the pointer/integer comparison diagnostic to include the types. llvm-svn: 41127
Diffstat (limited to 'clang/test/Parser/pointer_promotion.c')
-rw-r--r--clang/test/Parser/pointer_promotion.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/clang/test/Parser/pointer_promotion.c b/clang/test/Parser/pointer_promotion.c
new file mode 100644
index 00000000000..18cd9687b70
--- /dev/null
+++ b/clang/test/Parser/pointer_promotion.c
@@ -0,0 +1,18 @@
+// RUN: clang -parse-ast-check %s
+
+int test() {
+ void *vp;
+ int *ip;
+ char *cp;
+ struct foo *fp;
+ struct bar *bp;
+ short sint = 7;
+
+ if (ip < cp) ; // expected-warning {{comparison of distinct pointer types ('int *' and 'char *')}}
+ if (cp < fp) ; // expected-warning {{comparison of distinct pointer types ('char *' and 'struct foo *')}}
+ if (fp < bp) ; // expected-warning {{comparison of distinct pointer types ('struct foo *' and 'struct bar *')}}
+ if (ip < 7) ; // expected-warning {{comparison between pointer and integer ('int *' and 'int')}}
+ if (sint < ip) ; // expected-warning {{comparison between pointer and integer ('int' and 'int *')}}
+ if (ip == cp) ; // expected-warning {{comparison of distinct pointer types ('int *' and 'char *')}}
+}
+
OpenPOWER on IntegriCloud