]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Backport r251020
authorMartin Liska <mliska@suse.cz>
Fri, 15 Sep 2017 09:17:18 +0000 (11:17 +0200)
committerMartin Liska <marxin@gcc.gnu.org>
Fri, 15 Sep 2017 09:17:18 +0000 (09:17 +0000)
2017-09-15  Martin Liska  <mliska@suse.cz>

Backport from mainline
2017-08-10  Martin Liska  <mliska@suse.cz>

PR c++/81355
* c-attribs.c (handle_target_attribute):
Report warning for an empty string argument of target attribute.
2017-09-15  Martin Liska  <mliska@suse.cz>

Backport from mainline
2017-08-10  Martin Liska  <mliska@suse.cz>

PR c++/81355
* g++.dg/other/pr81355.C: New test.

From-SVN: r252795

gcc/ChangeLog
gcc/c-family/c-common.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/other/pr81355.C [new file with mode: 0644]

index 73e222133c44a96cd7e46e02106fa0105c1c83bb..5be04ffaec5fe7cda6e75a1ec1f0cb802c57dea1 100644 (file)
@@ -1,3 +1,12 @@
+2017-09-15  Martin Liska  <mliska@suse.cz>
+
+       Backport from mainline
+       2017-08-10  Martin Liska  <mliska@suse.cz>
+
+       PR c++/81355
+       * c-attribs.c (handle_target_attribute):
+       Report warning for an empty string argument of target attribute.
+
 2017-09-15  Martin Liska  <mliska@suse.cz>
 
        Backport from mainline
index dec1acbeb5a62974a1e9a38ab10dd54f031bc804..e769053a3ba2744a06ec8dcc8d0431745a150029 100644 (file)
@@ -9439,6 +9439,19 @@ handle_target_attribute (tree *node, tree name, tree args, int flags,
                                                      flags))
     *no_add_attrs = true;
 
+  /* Check that there's no empty string in values of the attribute.  */
+  for (tree t = args; t != NULL_TREE; t = TREE_CHAIN (t))
+    {
+      tree value = TREE_VALUE (t);
+      if (TREE_CODE (value) == STRING_CST
+         && TREE_STRING_LENGTH (value) == 1
+         && TREE_STRING_POINTER (value)[0] == '\0')
+       {
+         warning (OPT_Wattributes, "empty string in attribute %<target%>");
+         *no_add_attrs = true;
+       }
+    }
+
   return NULL_TREE;
 }
 
index 9fc32ee4b12ae7de77f4f54b7dc65050f36f8dd2..36c92edbf3f90b115a3bac7419164ce0046f0822 100644 (file)
@@ -1,3 +1,11 @@
+2017-09-15  Martin Liska  <mliska@suse.cz>
+
+       Backport from mainline
+       2017-08-10  Martin Liska  <mliska@suse.cz>
+
+       PR c++/81355
+       * g++.dg/other/pr81355.C: New test.
+
 2017-09-15  Martin Liska  <mliska@suse.cz>
 
        Backport from mainline
diff --git a/gcc/testsuite/g++.dg/other/pr81355.C b/gcc/testsuite/g++.dg/other/pr81355.C
new file mode 100644 (file)
index 0000000..89d1b41
--- /dev/null
@@ -0,0 +1,14 @@
+/* { dg-do compile { target x86_64-*-* } } */
+
+__attribute__((target("default")))
+int foo() {return 1;}
+
+__attribute__((target("arch=core2", "")))
+int foo2() {return 2;} /* { dg-warning "empty string in attribute .target." } */
+
+__attribute__((target("sse4.2", "", "")))
+int foo3() {return 2;} /* { dg-warning "empty string in attribute .target." } */
+
+int main() {
+    return foo() + foo2() + foo3();
+}