summaryrefslogtreecommitdiffstats
path: root/test/Analysis/casts.c
diff options
context:
space:
mode:
authorrdivacky <rdivacky@FreeBSD.org>2009-10-14 18:03:49 +0000
committerrdivacky <rdivacky@FreeBSD.org>2009-10-14 18:03:49 +0000
commit9092c3e0fa01f3139b016d05d267a89e3b07747a (patch)
tree137ebebcae16fb0ce7ab4af456992bbd8d22fced /test/Analysis/casts.c
parent4981926bf654fe5a2c3893f24ca44106b217e71e (diff)
downloadFreeBSD-src-9092c3e0fa01f3139b016d05d267a89e3b07747a.zip
FreeBSD-src-9092c3e0fa01f3139b016d05d267a89e3b07747a.tar.gz
Update clang to r84119.
Diffstat (limited to 'test/Analysis/casts.c')
-rw-r--r--test/Analysis/casts.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/test/Analysis/casts.c b/test/Analysis/casts.c
index 5e4222b..ae51ffb 100644
--- a/test/Analysis/casts.c
+++ b/test/Analysis/casts.c
@@ -1,9 +1,16 @@
-// RUN: clang-cc -analyze -checker-cfref -analyzer-store=region --verify %s
+// RUN: clang-cc -triple x86_64-apple-darwin9 -analyze -checker-cfref -analyzer-store=region --verify %s
// Test if the 'storage' region gets properly initialized after it is cast to
// 'struct sockaddr *'.
-#include <sys/socket.h>
+typedef unsigned char __uint8_t;
+typedef unsigned int __uint32_t;
+typedef __uint32_t __darwin_socklen_t;
+typedef __uint8_t sa_family_t;
+typedef __darwin_socklen_t socklen_t;
+struct sockaddr { sa_family_t sa_family; };
+struct sockaddr_storage {};
+
void f(int sock) {
struct sockaddr_storage storage;
struct sockaddr* sockaddr = (struct sockaddr*)&storage;
@@ -19,14 +26,14 @@ struct s {
struct s *value;
};
-int f1(struct s **pval) {
+void f1(struct s **pval) {
int *tbool = ((void*)0);
struct s *t = *pval;
pval = &(t->value);
- tbool = (int *)pval; // Should record the cast-to type here.
+ tbool = (int *)pval; // use the cast-to type 'int *' to create element region.
char c = (unsigned char) *tbool; // Should use cast-to type to create symbol.
- if (*tbool == -1)
- 3;
+ if (*tbool == -1) // here load the element region with the correct type 'int'
+ (void)3;
}
void f2(const char *str) {
OpenPOWER on IntegriCloud