Imported Upstream version 4.7.3
[platform/upstream/gcc48.git] / gcc / fortran / trans-decl.c
index e497fd6..217eb4a 100644 (file)
@@ -1369,6 +1369,12 @@ gfc_get_symbol_decl (gfc_symbol * sym)
        DECL_IGNORED_P (decl) = 1;
     }
 
+  if (sym->attr.select_type_temporary)
+    {
+      DECL_ARTIFICIAL (decl) = 1;
+      DECL_IGNORED_P (decl) = 1;
+    }
+
   if (sym->attr.dimension || sym->attr.codimension)
     {
       /* Create variables to hold the non-constant bits of array info.  */
@@ -1479,7 +1485,8 @@ gfc_get_symbol_decl (gfc_symbol * sym)
       && POINTER_TYPE_P (TREE_TYPE (decl))
       && !sym->attr.pointer
       && !sym->attr.allocatable
-      && !sym->attr.proc_pointer)
+      && !sym->attr.proc_pointer
+      && !sym->attr.select_type_temporary)
     DECL_BY_REFERENCE (decl) = 1;
 
   if (sym->attr.vtab
@@ -4586,22 +4593,25 @@ generate_local_decl (gfc_symbol * sym)
        }
 
       /* Warn for unused variables, but not if they're inside a common
-        block, a namelist, or are use-associated.  */
+        block or a namelist.  */
       else if (warn_unused_variable
-              && !(sym->attr.in_common || sym->attr.use_assoc || sym->mark
-                   || sym->attr.in_namelist))
+              && !(sym->attr.in_common || sym->mark || sym->attr.in_namelist))
        {
-         gfc_warning ("Unused variable '%s' declared at %L", sym->name,
-                      &sym->declared_at);
-         if (sym->backend_decl != NULL_TREE)
-           TREE_NO_WARNING(sym->backend_decl) = 1;
-       }
-      else if (warn_unused_variable && sym->attr.use_only)
-       {
-         gfc_warning ("Unused module variable '%s' which has been explicitly "
-                      "imported at %L", sym->name, &sym->declared_at);
-         if (sym->backend_decl != NULL_TREE)
-           TREE_NO_WARNING(sym->backend_decl) = 1;
+         if (sym->attr.use_only)
+           {
+             gfc_warning ("Unused module variable '%s' which has been "
+                          "explicitly imported at %L", sym->name,
+                          &sym->declared_at);
+             if (sym->backend_decl != NULL_TREE)
+               TREE_NO_WARNING(sym->backend_decl) = 1;
+           }
+         else if (!sym->attr.use_assoc)
+           {
+             gfc_warning ("Unused variable '%s' declared at %L",
+                          sym->name, &sym->declared_at);
+             if (sym->backend_decl != NULL_TREE)
+               TREE_NO_WARNING(sym->backend_decl) = 1;
+           }
        }
 
       /* For variable length CHARACTER parameters, the PARM_DECL already