1 /* This file contains routines to construct and validate Cilk Plus
2 constructs within the C and C++ front ends.
4 Copyright (C) 2013 Free Software Foundation, Inc.
5 Contributed by Aldy Hernandez <aldyh@redhat.com>.
7 This file is part of GCC.
9 GCC is free software; you can redistribute it and/or modify it
10 under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3, or (at your option)
14 GCC is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with GCC; see the file COPYING3. If not see
21 <http://www.gnu.org/licenses/>. */
25 #include "coretypes.h"
29 /* Validate the body of a _Cilk_for construct or a <#pragma simd> for
32 Returns true if there were no errors, false otherwise. */
35 c_check_cilk_loop (location_t loc
, tree decl
)
37 if (TREE_THIS_VOLATILE (decl
))
39 error_at (loc
, "iteration variable cannot be volatile");
45 /* Validate and emit code for <#pragma simd> clauses. */
48 c_finish_cilk_clauses (tree clauses
)
50 for (tree c
= clauses
; c
; c
= OMP_CLAUSE_CHAIN (c
))
54 /* If a variable appears in a linear clause it cannot appear in
55 any other OMP clause. */
56 if (OMP_CLAUSE_CODE (c
) == OMP_CLAUSE_LINEAR
)
57 for (tree c2
= clauses
; c2
; c2
= OMP_CLAUSE_CHAIN (c2
))
61 enum omp_clause_code code
= OMP_CLAUSE_CODE (c2
);
65 case OMP_CLAUSE_LINEAR
:
66 case OMP_CLAUSE_PRIVATE
:
67 case OMP_CLAUSE_FIRSTPRIVATE
:
68 case OMP_CLAUSE_LASTPRIVATE
:
69 case OMP_CLAUSE_REDUCTION
:
72 case OMP_CLAUSE_SAFELEN
:
79 if (OMP_CLAUSE_DECL (c
) == OMP_CLAUSE_DECL (c2
))
81 error_at (OMP_CLAUSE_LOCATION (c2
),
82 "variable appears in more than one clause");
83 inform (OMP_CLAUSE_LOCATION (c
),
84 "other clause defined here");
85 // Remove problematic clauses.
86 OMP_CLAUSE_CHAIN (prev
) = OMP_CLAUSE_CHAIN (c2
);