diagnose extended uses of offsetof

llvm-svn: 41653
This commit is contained in:
Chris Lattner 2007-08-31 21:49:13 +00:00
parent 51728b7282
commit 78502cf4c9
1 changed files with 6 additions and 0 deletions

View File

@ -1743,6 +1743,12 @@ Sema::ExprResult Sema::ParseBuiltinOffsetOf(SourceLocation BuiltinLoc,
// iteratively process the offsetof designators.
Expr *Res = new CompoundLiteralExpr(ArgTy, 0);
// offsetof with non-identifier designators (e.g. "offsetof(x, a.b[c])") are a
// GCC extension, diagnose them.
if (NumComponents != 1)
Diag(BuiltinLoc, diag::ext_offsetof_extended_field_designator,
SourceRange(CompPtr[1].LocStart, CompPtr[NumComponents-1].LocEnd));
for (unsigned i = 0; i != NumComponents; ++i) {
const OffsetOfComponent &OC = CompPtr[i];
if (OC.isBrackets) {