+/* gfc_conv_cray_pointee takes a sym with attribute cray_pointee and
+ swaps in the backend_decl of its corresponding pointer. There are
+ 2 cases; one for variable size arrays, and one for everything else,
+ because variable-sized arrays require one fewer level of
+ indirection. */
+
+tree
+gfc_conv_cray_pointee(gfc_symbol *sym)
+{
+ tree decl = gfc_get_symbol_decl (sym->cp_pointer);
+
+ /* Parameters need to be dereferenced. */
+ if (sym->cp_pointer->attr.dummy)
+ decl = gfc_build_indirect_ref (decl);
+
+ /* Check to see if we're dealing with a variable-sized array. */
+ if (sym->attr.dimension
+ && TREE_CODE (TREE_TYPE (sym->backend_decl)) == POINTER_TYPE)
+ {
+ /* These decls will be derefenced later, so we don't dereference
+ them here. */
+ decl = convert (TREE_TYPE (sym->backend_decl), decl);
+ }
+ else
+ {
+ decl = convert (build_pointer_type (TREE_TYPE (sym->backend_decl)),
+ decl);
+ decl = gfc_build_indirect_ref (decl);
+ }
+ return decl;
+}
+