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 Balaji V. Iyer <balaji.v.iyer@intel.com>,
6 Aldy Hernandez <aldyh@redhat.com>.
8 This file is part of GCC.
10 GCC is free software; you can redistribute it and/or modify it
11 under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 3, or (at your option)
15 GCC is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with GCC; see the file COPYING3. If not see
22 <http://www.gnu.org/licenses/>. */
26 #include "coretypes.h"
28 #include "diagnostic-core.h"
31 /* Callback for cp_walk_tree to validate the body of a pragma simd loop
34 This function is passed in as a function pointer to walk_tree. *TP is
35 the current tree pointer, *WALK_SUBTREES is set to 0 by this function if
36 recursing into TP's subtrees is unnecessary. *DATA is a bool variable that
37 is set to false if an error has occured. */
40 cpp_validate_cilk_plus_loop_aux (tree
*tp
, int *walk_subtrees
, void *data
)
42 bool *valid
= (bool *) data
;
43 location_t loc
= EXPR_HAS_LOCATION (*tp
) ? EXPR_LOCATION (*tp
) :
49 if (TREE_CODE (*tp
) == THROW_EXPR
)
51 error_at (loc
, "throw expressions are not allowed inside loops "
52 "marked with pragma simd");
56 else if (TREE_CODE (*tp
) == TRY_BLOCK
)
58 error_at (loc
, "try statements are not allowed inside loops marked "
67 /* Walks through all the subtrees of BODY using walk_tree to make sure
68 invalid statements/expressions are not found inside BODY. Returns
69 false if any invalid statements are found. */
72 cpp_validate_cilk_plus_loop (tree body
)
75 cp_walk_tree (&body
, cpp_validate_cilk_plus_loop_aux
,
76 (void *) &valid
, NULL
);