blob: 5c1090a097f7a198eb98a1e41f5ec3f1b39ca04e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
/* This file is part of the Intel(R) Cilk(TM) Plus support
This file contains routines to handle Cilk Plus specific
routines for the C++ Compiler.
Copyright (C) 2013 Free Software Foundation, Inc.
Contributed by Aldy Hernandez <aldyh@redhat.com>.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "cp-tree.h"
#include "diagnostic-core.h"
/* Callback for cp_walk_tree to validate the body of a pragma simd loop
or _cilk_for loop.
This function is passed in as a function pointer to walk_tree. *TP is
the current tree pointer, *WALK_SUBTREES is set to 0 by this function if
recursing into TP's subtrees is unnecessary. *DATA is a bool variable that
is set to false if an error has occured. */
static tree
cpp_validate_cilk_plus_loop_aux (tree *tp, int *walk_subtrees, void *data)
{
bool *valid = (bool *) data;
location_t loc = EXPR_HAS_LOCATION (*tp) ? EXPR_LOCATION (*tp) :
UNKNOWN_LOCATION;
if (!tp || !*tp)
return NULL_TREE;
if (TREE_CODE (*tp) == THROW_EXPR)
{
error_at (loc, "throw expressions are not allowed inside loops "
"marked with pragma simd");
*walk_subtrees = 0;
*valid = false;
}
else if (TREE_CODE (*tp) == TRY_BLOCK)
{
error_at (loc, "try statements are not allowed inside loops marked "
"with #pragma simd");
*valid = false;
*walk_subtrees = 0;
}
return NULL_TREE;
}
/* Walks through all the subtrees of BODY using walk_tree to make sure
invalid statements/expressions are not found inside BODY. Returns
false if any invalid statements are found. */
bool
cpp_validate_cilk_plus_loop (tree body)
{
bool valid = true;
cp_walk_tree (&body, cpp_validate_cilk_plus_loop_aux,
(void *) &valid, NULL);
return valid;
}
|