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::AddrOf:
|
||||||
case UnaryOperator::Deref:
|
case UnaryOperator::Deref:
|
||||||
return ICEDiag(2, E->getLocStart());
|
return ICEDiag(2, E->getLocStart());
|
||||||
case UnaryOperator::OffsetOf:
|
|
||||||
case UnaryOperator::Extension:
|
case UnaryOperator::Extension:
|
||||||
case UnaryOperator::LNot:
|
case UnaryOperator::LNot:
|
||||||
case UnaryOperator::Plus:
|
case UnaryOperator::Plus:
|
||||||
|
@ -1952,7 +1951,11 @@ static ICEDiag CheckICE(const Expr* E, ASTContext &Ctx) {
|
||||||
case UnaryOperator::Real:
|
case UnaryOperator::Real:
|
||||||
case UnaryOperator::Imag:
|
case UnaryOperator::Imag:
|
||||||
return CheckICE(Exp->getSubExpr(), Ctx);
|
return CheckICE(Exp->getSubExpr(), Ctx);
|
||||||
|
case UnaryOperator::OffsetOf:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// OffsetOf falls through here.
|
||||||
}
|
}
|
||||||
case Expr::OffsetOfExprClass: {
|
case Expr::OffsetOfExprClass: {
|
||||||
// Note that per C99, offsetof must be an ICE. And AFAIK, using
|
// 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) {
|
for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
|
||||||
const Node &ON = E->getComponent(I);
|
const Node &ON = E->getComponent(I);
|
||||||
Component Comp;
|
Component Comp;
|
||||||
|
Comp.isBrackets = true;
|
||||||
Comp.LocStart = ON.getRange().getBegin();
|
Comp.LocStart = ON.getRange().getBegin();
|
||||||
Comp.LocEnd = ON.getRange().getEnd();
|
Comp.LocEnd = ON.getRange().getEnd();
|
||||||
switch (ON.getKind()) {
|
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'}}
|
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