]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Backport r251020
authorMartin Liska <mliska@suse.cz>
Fri, 15 Sep 2017 12:14:01 +0000 (14:14 +0200)
committerMartin Liska <marxin@gcc.gnu.org>
Fri, 15 Sep 2017 12:14:01 +0000 (12:14 +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: r252811

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

index 4123cd032c7675047d831c1a8106bdf2a891b36c..c028b6147fc70e8de0fc9be0f999483e2f5b857d 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 e3e44518a6464e8380fabbbbbc6ad2bd1d846d91..35245703202e0d85155c4c18af5c03358af653b6 100644 (file)
@@ -9308,6 +9308,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 4af92529d7ac917bf45b3b12462a7095caccd289..dd465052bc79e4818df0d1a06a25d131337d9ecc 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();
+}