]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
compiler: Consider the depth of a nested composite literal during traversal.
authorIan Lance Taylor <ian@gcc.gnu.org>
Thu, 20 Mar 2014 19:37:50 +0000 (19:37 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Thu, 20 Mar 2014 19:37:50 +0000 (19:37 +0000)
Fixes issue 7590.

From-SVN: r208731

gcc/go/gofrontend/expressions.cc

index 6ac18f570e8694cebb3d0eab208562574f085dea..643a233ba004ff4ab4bab7b9e4964f7cb4fc9f5e 100644 (file)
@@ -13483,6 +13483,20 @@ Composite_literal_expression::do_traverse(Traverse* traverse)
     {
       // The type may not be resolvable at this point.
       Type* type = this->type_;
+
+      for (int depth = this->depth_; depth > 0; --depth)
+        {
+          if (type->array_type() != NULL)
+            type = type->array_type()->element_type();
+          else if (type->map_type() != NULL)
+            type = type->map_type()->val_type();
+          else
+            {
+              // This error will be reported during lowering.
+              return TRAVERSE_CONTINUE;
+            }
+        }
+
       while (true)
        {
          if (type->classification() == Type::TYPE_NAMED)