https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105234

--- Comment #10 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
2022-04-12  Jakub Jelinek  <ja...@redhat.com>

        PR target/105234
        * attribs.cc (decl_attributes): Don't set
        DECL_FUNCTION_SPECIFIC_TARGET if target_option_default_node is
        NULL.

--- gcc/attribs.cc.jj   2022-02-04 14:36:53.947620076 +0100
+++ gcc/attribs.cc      2022-04-12 12:52:36.630967329 +0200
@@ -636,15 +636,20 @@ decl_attributes (tree *node, tree attrib
       && !DECL_FUNCTION_SPECIFIC_OPTIMIZATION (*node))
     {
       DECL_FUNCTION_SPECIFIC_OPTIMIZATION (*node) = optimization_current_node;
-      tree cur_tree
-       = build_target_option_node (&global_options, &global_options_set);
-      tree old_tree = DECL_FUNCTION_SPECIFIC_TARGET (*node);
-      if (!old_tree)
-       old_tree = target_option_default_node;
-      /* The changes on optimization options can cause the changes in
-        target options, update it accordingly if it's changed.  */
-      if (old_tree != cur_tree)
-       DECL_FUNCTION_SPECIFIC_TARGET (*node) = cur_tree;
+      /* Don't set DECL_FUNCTION_SPECIFIC_TARGET for targets that don't
+        support #pragma GCC target or target attribute.  */
+      if (target_option_default_node)
+       {
+         tree cur_tree
+           = build_target_option_node (&global_options, &global_options_set);
+         tree old_tree = DECL_FUNCTION_SPECIFIC_TARGET (*node);
+         if (!old_tree)
+           old_tree = target_option_default_node;
+         /* The changes on optimization options can cause the changes in
+            target options, update it accordingly if it's changed.  */
+         if (old_tree != cur_tree)
+           DECL_FUNCTION_SPECIFIC_TARGET (*node) = cur_tree;
+       }
     }

   /* If this is a function and the user used #pragma GCC target, add the

certainly works for me.

Reply via email to