On 09/12/2013 04:55 AM, Jakub Jelinek wrote:
-      if (t1 != t2)
+      if (t1 != t2 && !DECL_OMP_DECLARE_REDUCTION_P (newdecl))
        return 0;

What's the theory here? Why should decls_match return true for reductions with mismatching templates?

+         && ! (DECL_OMP_DECLARE_REDUCTION_P (newdecl)
+               && DECL_CONTEXT (newdecl) == NULL_TREE
+               && DECL_CONTEXT (olddecl) == current_function_decl))

And this looks like you need to set DECL_CONTEXT sooner on reductions.

+           if (TREE_CODE (argtype) == REFERENCE_TYPE)
+             error_at (DECL_SOURCE_LOCATION (t),
+                       "function, array or reference type in "
+                       "%<#pragma omp declare reduction%>");

Let's just say "reference type", since we know that's what it is.

+                        && DECL_CONTEXT (pattern_decl)
+                        && TREE_CODE (DECL_CONTEXT (pattern_decl))
+                           == FUNCTION_DECL)

This is DECL_FUNCTION_SCOPE_P.

+  return TREE_CODE (TREE_TYPE (decl)) == REFERENCE_TYPE
+        || is_invisiref_parm (decl);

Needs parens to protect indentation.

+/* Instantiate the special body of the artificial DECL_OMP_DECLARE_REDUCTION
+   function.  */

We could use documentation of what this special body looks like, either here, in cp_check_omp_declare_reduction, or elsewhere.

+      for (ix = 0; BINFO_BASE_ITERATE (binfo, ix, base_binfo); ix++)
+       {
+         id = omp_reduction_lookup (loc, orig_id, BINFO_TYPE (base_binfo));
+         if (id != NULL_TREE)
+           return id;

This should check for ambiguity rather than returning the first match.

+   Also append INIT_EXPR for DECL_INITIAL of omp_priv after its
+   DECL_EXPR.  */

Why not let the DECL_EXPR handle initialization?

Let's break out the finish_omp_clauses reduction code into a separate function, as it's rather large.

+                   if (DECL_TEMPLATE_INFO (id))
+                     id = instantiate_decl (id, /*defer_ok*/0, true);

Let's use mark_used instead.

+                   if (TREE_CODE (body) == STATEMENT_LIST)
+                     {

Maybe this should be an assert?

Jason

Reply via email to