PR tree-optimization/81303
[official-gcc.git] / gcc / testsuite / gcc.dg / pr46571.c
blob435812210ea5849becc965528f2bd955cd6d43e7
1 /* { dg-do compile } */
2 /* { dg-options "-O2 -fcompare-debug -w" } */
4 typedef union tree_node *tree;
5 typedef unsigned int source_location;
6 enum tree_code
8 MINUS_EXPR,
9 MULT_EXPR,
11 struct tree_omp_clause
13 union omp_clause_subcode
15 enum tree_code reduction_code;
16 } subcode;
18 union tree_node
20 struct tree_omp_clause omp_clause;
22 enum tree_index
24 TI_ERROR_MARK,
26 typedef struct
28 unsigned allocatable:1;
29 unsigned dimension:1;
30 unsigned codimension:1;
31 unsigned external:1;
32 unsigned optional:1;
33 unsigned pointer:1;
34 unsigned contiguous:1;
35 unsigned referenced:1;
36 } symbol_attribute;
37 typedef unsigned int gfc_char_t;
38 typedef struct gfc_linebuf
40 source_location location;
41 } gfc_linebuf;
42 typedef struct
44 gfc_char_t *nextc;
45 gfc_linebuf *lb;
46 } locus;
47 typedef struct
49 struct gfc_symbol *sym;
50 struct gfc_namelist *next;
51 } gfc_namelist;
52 enum
54 OMP_LIST_PLUS,
55 OMP_LIST_REDUCTION_FIRST = OMP_LIST_PLUS,
56 OMP_LIST_MULT,
57 OMP_LIST_SUB,
58 OMP_LIST_NUM
60 typedef struct gfc_omp_clauses
62 gfc_namelist *lists[OMP_LIST_NUM];
63 } gfc_omp_clauses;
64 typedef struct gfc_symbol
66 symbol_attribute attr;
67 } gfc_symbol;
68 typedef struct gfc_code
70 locus loc;
71 union
73 gfc_omp_clauses *omp_clauses;
74 } ext;
75 } gfc_code;
76 typedef struct
78 } stmtblock_t;
80 static tree
81 gfc_trans_omp_reduction_list (gfc_namelist * namelist, tree list,
82 enum tree_code reduction_code, locus where)
84 for (; namelist != ((void *) 0); namelist = namelist->next)
85 if (namelist->sym->attr.referenced)
87 tree node = build_omp_clause (where.lb->location);
88 node->omp_clause.subcode.reduction_code = reduction_code;
89 gfc_trans_omp_array_reduction (namelist->sym, where);
93 static tree
94 gfc_trans_omp_clauses (stmtblock_t * block, gfc_omp_clauses * clauses,
95 locus where)
97 tree omp_clauses = (tree) ((void *) 0);
98 int list;
99 for (list = 0; list < OMP_LIST_NUM; list++)
101 gfc_namelist *n = clauses->lists[list];
102 enum tree_code reduction_code;
103 if (n == ((void *) 0))
104 continue;
105 switch (list)
107 case OMP_LIST_MULT:
108 reduction_code = MULT_EXPR;
109 break;
110 case OMP_LIST_SUB:
111 reduction_code = MINUS_EXPR;
113 gfc_trans_omp_reduction_list (n, omp_clauses, reduction_code, where);
117 void
118 gfc_trans_omp_parallel_workshare (gfc_code * code)
120 stmtblock_t block;
121 gfc_trans_omp_clauses (&block, code->ext.omp_clauses, code->loc);