[cfe-commits] r51920 - in /cfe/trunk: lib/AST/Expr.cpp test/Sema/darwin-align-cast.c
Steve Naroff
snaroff at apple.com
Tue Jun 3 15:06:05 PDT 2008
Author: snaroff
Date: Tue Jun 3 17:06:04 2008
New Revision: 51920
URL: http://llvm.org/viewvc/llvm-project?rev=51920&view=rev
Log:
Put back my temporary hack until Eli addresses this in a more complete fashion.
Added:
cfe/trunk/test/Sema/darwin-align-cast.c
Modified:
cfe/trunk/lib/AST/Expr.cpp
Modified: cfe/trunk/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=51920&r1=51919&r2=51920&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Tue Jun 3 17:06:04 2008
@@ -918,6 +918,11 @@
if (!SubExpr->getType()->isArithmeticType() ||
!getType()->isIntegerType()) {
if (Loc) *Loc = SubExpr->getLocStart();
+ // GCC accepts pointers as an extension.
+ // FIXME: check getLangOptions().NoExtensions. At the moment, it doesn't
+ // appear possible to get langOptions() from the Expr.
+ if (SubExpr->getType()->isPointerType()) // && !NoExtensions
+ return true;
return false;
}
Added: cfe/trunk/test/Sema/darwin-align-cast.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/darwin-align-cast.c?rev=51920&view=auto
==============================================================================
--- cfe/trunk/test/Sema/darwin-align-cast.c (added)
+++ cfe/trunk/test/Sema/darwin-align-cast.c Tue Jun 3 17:06:04 2008
@@ -0,0 +1,23 @@
+// RUN: clang -fsyntax-only -verify %s
+typedef long unsigned int __darwin_size_t;
+typedef long __darwin_ssize_t;
+typedef __darwin_size_t size_t;
+typedef __darwin_ssize_t ssize_t;
+
+struct cmsghdr {};
+
+#if 0
+This code below comes from the following system headers:
+sys/socket.h:#define CMSG_SPACE(l) (__DARWIN_ALIGN(sizeof(struct
+cmsghdr)) + __DARWIN_ALIGN(l))
+
+i386/_param.h:#define __DARWIN_ALIGN(p) ((__darwin_size_t)((char *)(p)
++ __DARWIN_ALIGNBYTES) &~ __DARWIN_ALIGNBYTES)
+#endif
+
+ssize_t sendFileDescriptor(int fd, void *data, size_t nbytes, int sendfd) {
+ union {
+ char control[(((__darwin_size_t)((char *)(sizeof(struct cmsghdr)) + (sizeof(__darwin_size_t) - 1)) &~ (sizeof(__darwin_size_t) - 1)) + ((__darwin_size_t)((char *)(sizeof(int)) + (sizeof(__darwin_size_t) - 1)) &~ (sizeof(__darwin_size_t) - 1)))];
+ } control_un;
+}
+
More information about the cfe-commits
mailing list