* Makefile.in (C_COMMON_OBJS): Depend on c-cilkplus.o.
[official-gcc.git] / gcc / cp / cp-cilkplus.c
blob5c1090a097f7a198eb98a1e41f5ec3f1b39ca04e
1 /* This file is part of the Intel(R) Cilk(TM) Plus support
2 This file contains routines to handle Cilk Plus specific
3 routines for the C++ Compiler.
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)
12 any later version.
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/>. */
23 #include "config.h"
24 #include "system.h"
25 #include "coretypes.h"
26 #include "cp-tree.h"
27 #include "diagnostic-core.h"
30 /* Callback for cp_walk_tree to validate the body of a pragma simd loop
31 or _cilk_for loop.
33 This function is passed in as a function pointer to walk_tree. *TP is
34 the current tree pointer, *WALK_SUBTREES is set to 0 by this function if
35 recursing into TP's subtrees is unnecessary. *DATA is a bool variable that
36 is set to false if an error has occured. */
38 static tree
39 cpp_validate_cilk_plus_loop_aux (tree *tp, int *walk_subtrees, void *data)
41 bool *valid = (bool *) data;
42 location_t loc = EXPR_HAS_LOCATION (*tp) ? EXPR_LOCATION (*tp) :
43 UNKNOWN_LOCATION;
45 if (!tp || !*tp)
46 return NULL_TREE;
48 if (TREE_CODE (*tp) == THROW_EXPR)
50 error_at (loc, "throw expressions are not allowed inside loops "
51 "marked with pragma simd");
52 *walk_subtrees = 0;
53 *valid = false;
55 else if (TREE_CODE (*tp) == TRY_BLOCK)
57 error_at (loc, "try statements are not allowed inside loops marked "
58 "with #pragma simd");
59 *valid = false;
60 *walk_subtrees = 0;
62 return NULL_TREE;
66 /* Walks through all the subtrees of BODY using walk_tree to make sure
67 invalid statements/expressions are not found inside BODY. Returns
68 false if any invalid statements are found. */
70 bool
71 cpp_validate_cilk_plus_loop (tree body)
73 bool valid = true;
74 cp_walk_tree (&body, cpp_validate_cilk_plus_loop_aux,
75 (void *) &valid, NULL);
76 return valid;