]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/c-family/c-cilkplus.c
Makefile.in (C_COMMON_OBJS): Depend on c-cilkplus.o.
[thirdparty/gcc.git] / gcc / c-family / c-cilkplus.c
1 /* This file contains routines to construct and validate Cilk Plus
2 constructs within the C and C++ front ends.
3
4 Copyright (C) 2013 Free Software Foundation, Inc.
5 Contributed by Aldy Hernandez <aldyh@redhat.com>.
6
7 This file is part of GCC.
8
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)
12 any later version.
13
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.
18
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/>. */
22
23 #include "config.h"
24 #include "system.h"
25 #include "coretypes.h"
26 #include "tree.h"
27 #include "c-common.h"
28
29 /* Validate the body of a _Cilk_for construct or a <#pragma simd> for
30 loop.
31
32 Returns true if there were no errors, false otherwise. */
33
34 bool
35 c_check_cilk_loop (location_t loc, tree decl)
36 {
37 if (TREE_THIS_VOLATILE (decl))
38 {
39 error_at (loc, "iteration variable cannot be volatile");
40 return false;
41 }
42 return true;
43 }
44
45 /* Validate and emit code for <#pragma simd> clauses. */
46
47 tree
48 c_finish_cilk_clauses (tree clauses)
49 {
50 for (tree c = clauses; c; c = OMP_CLAUSE_CHAIN (c))
51 {
52 tree prev = clauses;
53
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))
58 {
59 if (c == c2)
60 continue;
61 enum omp_clause_code code = OMP_CLAUSE_CODE (c2);
62
63 switch (code)
64 {
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:
70 break;
71
72 case OMP_CLAUSE_SAFELEN:
73 goto next;
74
75 default:
76 gcc_unreachable ();
77 }
78
79 if (OMP_CLAUSE_DECL (c) == OMP_CLAUSE_DECL (c2))
80 {
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);
87 }
88 next:
89 prev = c2;
90 }
91 }
92 return clauses;
93 }