]> granicus.if.org Git - clang/commitdiff
PR3269: create an empty InitListExpr as a child for the
authorEli Friedman <eli.friedman@gmail.com>
Mon, 26 Jan 2009 01:33:06 +0000 (01:33 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Mon, 26 Jan 2009 01:33:06 +0000 (01:33 +0000)
CompoundLiteralExpr so that there aren't any null pointers in the AST.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62981 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExpr.cpp

index 1d55ed7c3aa4e450ba8c54daa88bc345497df7c1..9b91ec6ee5f496aa8aa94c366398c1081873d435 100644 (file)
@@ -3987,9 +3987,13 @@ Sema::ExprResult Sema::ActOnBuiltinOffsetOf(Scope *S,
   
   // Otherwise, create a compound literal expression as the base, and
   // iteratively process the offsetof designators.
-  Expr *Res = new (Context) CompoundLiteralExpr(SourceLocation(), ArgTy, 0, 
-                                                false);
-  
+  InitListExpr *IList =
+      new (Context) InitListExpr(SourceLocation(), 0, 0,
+                                 SourceLocation(), false);
+  IList->setType(ArgTy);
+  Expr *Res =
+      new (Context) CompoundLiteralExpr(SourceLocation(), ArgTy, IList, false);
+
   // offsetof with non-identifier designators (e.g. "offsetof(x, a.b[c])") are a
   // GCC extension, diagnose them.
   if (NumComponents != 1)