aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/AST/Expr.cpp5
-rw-r--r--lib/Sema/TreeTransform.h1
-rw-r--r--test/Sema/offsetof.c3
3 files changed, 8 insertions, 1 deletions
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp
index 82526119e2..00662a53af 100644
--- a/lib/AST/Expr.cpp
+++ b/lib/AST/Expr.cpp
@@ -1943,7 +1943,6 @@ static ICEDiag CheckICE(const Expr* E, ASTContext &Ctx) {
case UnaryOperator::AddrOf:
case UnaryOperator::Deref:
return ICEDiag(2, E->getLocStart());
- case UnaryOperator::OffsetOf:
case UnaryOperator::Extension:
case UnaryOperator::LNot:
case UnaryOperator::Plus:
@@ -1952,7 +1951,11 @@ static ICEDiag CheckICE(const Expr* E, ASTContext &Ctx) {
case UnaryOperator::Real:
case UnaryOperator::Imag:
return CheckICE(Exp->getSubExpr(), Ctx);
+ case UnaryOperator::OffsetOf:
+ break;
}
+
+ // OffsetOf falls through here.
}
case Expr::OffsetOfExprClass: {
// Note that per C99, offsetof must be an ICE. And AFAIK, using
diff --git a/lib/Sema/TreeTransform.h b/lib/Sema/TreeTransform.h
index 445cf17aad..5ce268bd9e 100644
--- a/lib/Sema/TreeTransform.h
+++ b/lib/Sema/TreeTransform.h
@@ -4202,6 +4202,7 @@ TreeTransform<Derived>::TransformOffsetOfExpr(OffsetOfExpr *E) {
for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
const Node &ON = E->getComponent(I);
Component Comp;
+ Comp.isBrackets = true;
Comp.LocStart = ON.getRange().getBegin();
Comp.LocEnd = ON.getRange().getEnd();
switch (ON.getKind()) {
diff --git a/test/Sema/offsetof.c b/test/Sema/offsetof.c
index cf88465e53..5026193943 100644
--- a/test/Sema/offsetof.c
+++ b/test/Sema/offsetof.c
@@ -62,3 +62,6 @@ struct has_bitfields {
};
int test3 = __builtin_offsetof(struct has_bitfields, j); // expected-error{{cannot compute offset of bit-field 'j'}}
+
+typedef struct Array { int array[1]; } Array;
+int test4 = __builtin_offsetof(Array, array);