aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/AST/Expr.cpp1
-rw-r--r--test/Sema/PR2727.c3
-rw-r--r--test/Sema/PR2728.c9
3 files changed, 13 insertions, 0 deletions
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp
index 49c76a89d8..1410f7e05c 100644
--- a/lib/AST/Expr.cpp
+++ b/lib/AST/Expr.cpp
@@ -814,6 +814,7 @@ bool Expr::isIntegerConstantExpr(llvm::APSInt &Result, ASTContext &Ctx,
Result = ~Result;
break;
case UnaryOperator::OffsetOf:
+ Result.zextOrTrunc(static_cast<uint32_t>(Ctx.getTypeSize(getType())));
Result = Exp->evaluateOffsetOf(Ctx);
}
break;
diff --git a/test/Sema/PR2727.c b/test/Sema/PR2727.c
index faf934d947..1b3096f0b5 100644
--- a/test/Sema/PR2727.c
+++ b/test/Sema/PR2727.c
@@ -1,3 +1,6 @@
+// RUN: clang -verify -fsyntax-only -std=c90 %s &&
+// RUN: clang -verify -fsyntax-only -std=c99 %s
+
int f (int x)
{
// sizeof applied to a type should not delete the type.
diff --git a/test/Sema/PR2728.c b/test/Sema/PR2728.c
new file mode 100644
index 0000000000..01a3be7b9e
--- /dev/null
+++ b/test/Sema/PR2728.c
@@ -0,0 +1,9 @@
+// RUN: clang -verify -fsyntax-only -std=c90 %s &&
+// RUN: clang -verify -fsyntax-only -std=c99 %s
+
+struct s
+{
+ int a;
+};
+
+int a[__builtin_offsetof(struct s, a) == 0];