diff options
author | Steve Naroff <snaroff@apple.com> | 2008-06-03 22:06:04 +0000 |
---|---|---|
committer | Steve Naroff <snaroff@apple.com> | 2008-06-03 22:06:04 +0000 |
commit | c793808539b2ed6ec3324ff9ba0f57aa54e027ca (patch) | |
tree | ab432fcd89eac4e5352bb4258b21d4872f82b267 | |
parent | 0a8b4e3f7d246a637fea77327020fbeebf2bab30 (diff) |
Put back my temporary hack until Eli addresses this in a more complete fashion.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51920 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/AST/Expr.cpp | 5 | ||||
-rw-r--r-- | test/Sema/darwin-align-cast.c | 23 |
2 files changed, 28 insertions, 0 deletions
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp index 357d711978..a89fbd621a 100644 --- a/lib/AST/Expr.cpp +++ b/lib/AST/Expr.cpp @@ -918,6 +918,11 @@ bool Expr::isIntegerConstantExpr(llvm::APSInt &Result, ASTContext &Ctx, 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; } diff --git a/test/Sema/darwin-align-cast.c b/test/Sema/darwin-align-cast.c new file mode 100644 index 0000000000..adf938f29b --- /dev/null +++ b/test/Sema/darwin-align-cast.c @@ -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; +} + |