]> granicus.if.org Git - clang/commitdiff
diagnose extended uses of offsetof
authorChris Lattner <sabre@nondot.org>
Fri, 31 Aug 2007 21:49:13 +0000 (21:49 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 31 Aug 2007 21:49:13 +0000 (21:49 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41653 91177308-0d34-0410-b5e6-96231b3b80d8

Sema/SemaExpr.cpp

index 3b65ab2bc1ded1ad0007aebfd69e39ba5d82c18e..daddb50c7179ac3291eb7f611c1a62cec59036ef 100644 (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) {