forked from OSchip/llvm-project
Fix a thinko that caused us not to compute __builtin_offset as a
constant expression in C. llvm-svn: 102762
This commit is contained in:
parent
3ca9a9b59c
commit
0be628ff64
|
@ -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
|
||||
|
|
|
@ -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()) {
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue