@@ -1,3 +1,10 @@
+2019-01-30 Kwok Cheung Yeung <kcy@codesourcery.com>
+
+ * omp-general.c (omp_is_optional_argument): New.
+ * omp-general.h (omp_is_optional_argument): New.
+ * omp-low.c (lower_omp_target): Use size of referenced object when
+ optional argument used as argument to firstprivate.
+
2019-01-30 Thomas Schwinge <thomas@codesourcery.com>
* doc/invoke.texi (C Language Options): List "-fopenacc-dim".
@@ -46,6 +46,15 @@ omp_find_clause (tree clauses, enum omp_clause_code kind)
return NULL_TREE;
}
+/* Return true if DECL is a Fortran optional argument. */
+
+bool
+omp_is_optional_argument (tree decl)
+{
+ return TREE_CODE (decl) == PARM_DECL && DECL_BY_REFERENCE (decl)
+ && TREE_CODE (TREE_TYPE (decl)) == POINTER_TYPE;
+}
+
/* Return true if DECL is a reference type. */
bool
@@ -72,6 +72,7 @@ struct omp_for_data
#define OACC_FN_ATTRIB "oacc function"
extern tree omp_find_clause (tree clauses, enum omp_clause_code kind);
+extern bool omp_is_optional_argument (tree decl);
extern bool omp_is_reference (tree decl);
extern void omp_adjust_for_condition (location_t loc, enum tree_code
*cond_code,
tree *n2);
@@ -8749,7 +8749,8 @@ lower_omp_target (gimple_stmt_iterator *gsi_p,
omp_context *ctx)
else
{
s = TREE_TYPE (ovar);
- if (TREE_CODE (s) == REFERENCE_TYPE)
+ if (TREE_CODE (s) == REFERENCE_TYPE
+ || omp_is_optional_argument (ovar))
s = TREE_TYPE (s);
s = TYPE_SIZE_UNIT (s);