Fix immutable frozen set bug in defs.bzl

When adding tags to a native cc_library rule that is created through a macro we
were not properly considering the case where the tags came from a different
file and therefore were frozen. This caused an error.

RELNOTES:none
PiperOrigin-RevId: 283039855
Change-Id: Id4cb45675a08ca65196f4f7771abdd5bb0705b79
diff --git a/cc/defs.bzl b/cc/defs.bzl
index a768a5c..ace104c 100644
--- a/cc/defs.bzl
+++ b/cc/defs.bzl
@@ -21,7 +21,7 @@
 
 def _add_tags(attrs):
     if "tags" in attrs and attrs["tags"] != None:
-        attrs["tags"] += [_MIGRATION_TAG]
+        attrs["tags"] = attrs["tags"] + [_MIGRATION_TAG]
     else:
         attrs["tags"] = [_MIGRATION_TAG]
     return attrs
diff --git a/tests/load_from_macro/BUILD b/tests/load_from_macro/BUILD
new file mode 100644
index 0000000..7084344
--- /dev/null
+++ b/tests/load_from_macro/BUILD
@@ -0,0 +1,24 @@
+# Copyright 2019 The Bazel Authors. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+load("//cc:defs.bzl", "cc_library")
+load(":tags.bzl", "TAGS")
+
+licenses(["notice"])
+
+cc_library(
+    name = "foo",
+    srcs = ["foo.cc"],
+    tags = TAGS,
+)
diff --git a/tests/load_from_macro/foo.cc b/tests/load_from_macro/foo.cc
new file mode 100644
index 0000000..c19005a
--- /dev/null
+++ b/tests/load_from_macro/foo.cc
@@ -0,0 +1,13 @@
+// Copyright 2019 The Bazel Authors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//    http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
diff --git a/tests/load_from_macro/tags.bzl b/tests/load_from_macro/tags.bzl
new file mode 100644
index 0000000..aa604c3
--- /dev/null
+++ b/tests/load_from_macro/tags.bzl
@@ -0,0 +1,17 @@
+# Copyright 2019 The Bazel Authors. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+"""
+Example tags defined in a separate file.
+"""
+TAGS = ["first_tag", "second_tag"]