RTEMS: Add Cortex-M33 multilib
[gcc.git] / gcc / testsuite / g++.dg / pr57662.C
bloba23bfc9f2fb90490315e658129b38e5c02b5642d
1 /* { dg-do compile { target powerpc*-*-* ia64-*-* i?86-*-* x86_64-*-* } } */
2 /* { dg-options "-O2 -fselective-scheduling2 -fsel-sched-pipelining -Wno-return-type" } */
4 extern "C" {
5         typedef struct _IO_FILE FILE;
6         extern int putc(int __c, FILE * __stream);
7         extern int strcmp(__const char *__s1, __const char *__s2) throw()
8             __attribute__ ((__pure__)) __attribute__ ((__nonnull__(1, 2)));
9 } typedef union tree_node *tree;
10 struct gcc_options {
11         int x_flag_openmp;
13 extern struct gcc_options global_options;
14 struct ht_identifier {
15         const unsigned char *str;
17 enum cpp_ttype {
18         CPP_SEMICOLON, CPP_NAME
20 struct vl_embed {
22 struct va_heap {
24 struct va_gc {
25         typedef vl_embed default_layout;
27 template < typename T, typename A = va_heap, typename L =
28     typename A::default_layout > struct vec {
30 enum tree_code {
31         ERROR_MARK,
32         IDENTIFIER_NODE,
33         OMP_SIMD,
34         MAX_TREE_CODES
36 struct tree_identifier {
37         struct ht_identifier
38          id;
40 union tree_node {
41         struct tree_identifier
42          identifier;
44 inline tree
45 tree_check(tree __t, const char *__f, int __l, const char *__g, tree_code __c)
49 extern tree chainon(tree, tree);
50 extern vec < tree, va_gc > *make_tree_vector(void);
51 typedef unsigned long omp_clause_mask;
52 enum c_omp_clause_split {
53         C_OMP_CLAUSE_SPLIT_TARGET = 0, C_OMP_CLAUSE_SPLIT_COUNT
55 typedef struct cxx_saved_binding {
56         tree attributes;
57 } cp_decl_specifier_seq;
58 typedef enum pragma_kind {
59         PRAGMA_NONE = 0, PRAGMA_OMP_DECLARE_REDUCTION, PRAGMA_OMP_TARGET
60 } pragma_kind;
61 typedef enum pragma_omp_clause {
62         PRAGMA_OMP_CLAUSE_NONE =
63             0, PRAGMA_OMP_CLAUSE_DEVICE, PRAGMA_OMP_CLAUSE_IF,
64             PRAGMA_OMP_CLAUSE_MAP
65 } pragma_omp_clause;
66 typedef struct cp_token {
67         enum cpp_ttype type:8;
68         union cp_token_value {
69                 tree value;
70         } u;
71 } cp_token;
72 typedef struct cp_token *cp_token_position;
73 typedef struct cp_lexer {
74         cp_token_position next_token;
75         bool debugging_p;
76         cp_lexer *lexer;
77 } cp_parser;
78 static FILE *cp_lexer_debug_stream;
79 static inline bool cp_lexer_debugging_p(cp_lexer * lexer)
81         return lexer->debugging_p;
84 static inline cp_token *cp_lexer_peek_token(cp_lexer * lexer)
86         if (cp_lexer_debugging_p(lexer)) {
87                 putc('\n', cp_lexer_debug_stream);
88         }
89         return lexer->next_token;
92 static inline bool cp_lexer_next_token_is(cp_lexer * lexer, enum cpp_ttype type)
96 enum {
97         CP_PARSER_FLAGS_NONE = 0x0, CP_PARSER_FLAGS_OPTIONAL =
98             0x1, CP_PARSER_FLAGS_NO_USER_DEFINED_TYPES =
99             0x2, CP_PARSER_FLAGS_NO_TYPE_DEFINITIONS =
100             0x4, CP_PARSER_FLAGS_ONLY_TYPE_OR_CONSTEXPR = 0x8
102 typedef int cp_parser_flags;
103 extern tree
104 cp_parser_type_specifier(cp_parser *, cp_parser_flags,
105                          cp_decl_specifier_seq *, bool, int *, bool *);
106 static void
107 cp_parser_type_specifier_seq(cp_parser *, bool, bool, cp_decl_specifier_seq *);
108 extern bool cp_next_tokens_can_be_attribute_p(cp_parser *);
109 extern tree cp_parser_attributes_opt(cp_parser *);
110 enum pragma_context {
111         pragma_external,
112         pragma_member,
113         pragma_objc_icode,
114         pragma_stmt,
115         pragma_compound
117 static bool cp_parser_pragma(cp_parser *, enum pragma_context);
118 static bool cp_parser_translation_unit(cp_parser * parser)
120         while (true) {
121                 cp_token *token;
122                 if (token->type == CPP_SEMICOLON) {
123                         cp_parser_pragma(parser, pragma_external);
124                 }
125         }
128 static tree
129 cp_parser_type_id_1(cp_parser * parser, bool is_template_arg,
130                     bool is_trailing_return)
132         cp_decl_specifier_seq type_specifier_seq;
133         cp_parser_type_specifier_seq(parser, false, is_trailing_return,
134                                      &type_specifier_seq);
137 static tree cp_parser_type_id(cp_parser * parser)
139         return cp_parser_type_id_1(parser, false, false);
142 static void
143 cp_parser_type_specifier_seq(cp_parser * parser, bool is_declaration,
144                              bool is_trailing_return,
145                              cp_decl_specifier_seq * type_specifier_seq)
147         cp_parser_flags flags = CP_PARSER_FLAGS_OPTIONAL;
148         cp_token *start_token = __null;
149         while (true) {
150                 tree type_specifier;
151                 bool is_cv_qualifier;
152                 if (cp_next_tokens_can_be_attribute_p(parser)) {
153                         type_specifier_seq->attributes =
154                             chainon(type_specifier_seq->attributes,
155                                     cp_parser_attributes_opt(parser));
156                         continue;
157                 }
158                 if (!start_token)
159                         start_token = cp_lexer_peek_token(parser->lexer);
160                 type_specifier =
161                     cp_parser_type_specifier(parser, flags, type_specifier_seq,
162                                              false, __null, &is_cv_qualifier);
163                 if (!type_specifier) {
164                         break;
165                 }
166                 if (is_declaration && !is_cv_qualifier)
167                         flags |= CP_PARSER_FLAGS_NO_USER_DEFINED_TYPES;
168         }
171 static bool
172 cp_parser_omp_for_loop_init(cp_parser * parser, bool parsing_openmp,
173                             tree & this_pre_body, vec < tree,
174                             va_gc > *for_block, tree & init, tree & decl,
175                             tree & real_decl)
177         cp_decl_specifier_seq type_specifiers;
178         cp_parser_type_specifier_seq(parser, true, false, &type_specifiers);
181 static tree
182 cp_parser_omp_for_loop(cp_parser * parser, enum tree_code code, tree clauses,
183                        tree * cclauses)
185         tree init, cond, incr, body, decl, pre_body = (tree) __null, ret;
186         tree real_decl, initv, condv, incrv, declv;
187         tree this_pre_body, cl;
188         int i, collapse = 1, nbraces = 0;
189         vec < tree, va_gc > *for_block = make_tree_vector();
190         for (i = 0; i < collapse; i++) {
191                 bool add_private_clause = false;
192                 add_private_clause |=
193                     cp_parser_omp_for_loop_init(parser, true,
194                                                 this_pre_body, for_block, init,
195                                                 decl, real_decl);
196         }
199 static tree
200 cp_parser_omp_simd(cp_parser * parser, cp_token * pragma_tok, char *p_name,
201                    omp_clause_mask mask, tree * cclauses)
203         tree clauses, sb, ret;
204         ret = cp_parser_omp_for_loop(parser, OMP_SIMD, clauses, cclauses);
207 static tree
208 cp_parser_omp_distribute(cp_parser * parser, cp_token * pragma_tok,
209                          char *p_name, omp_clause_mask mask, tree * cclauses)
211         if (cp_lexer_next_token_is(parser->lexer, CPP_NAME)) {
212                 tree id = cp_lexer_peek_token(parser->lexer)->u.value;
213                 const char *p =
214                     ((const char
215                       *)(tree_check((id),
216                                     "/home/bonzo/develop/trunk/gcc/cp/parser.c",
217                                     29966, __FUNCTION__,
218                                     (IDENTIFIER_NODE)))->identifier.id.str);
219                 bool simd = false;
220                 bool parallel = false;
221                 if (strcmp(p, "simd") == 0)
222                         simd = true;
223                 if (parallel || simd) {
224                         if (!global_options.x_flag_openmp) {
225                                 if (simd)
226                                         return cp_parser_omp_simd(parser,
227                                                                   pragma_tok,
228                                                                   p_name, mask,
229                                                                   cclauses);
230                         }
231                 }
232         }
235 static tree
236 cp_parser_omp_teams(cp_parser * parser, cp_token * pragma_tok, char *p_name,
237                     omp_clause_mask mask, tree * cclauses)
239         if (cp_lexer_next_token_is(parser->lexer, CPP_NAME)) {
240                 tree id = cp_lexer_peek_token(parser->lexer)->u.value;
241                 const char *p =
242                     ((const char
243                       *)(tree_check((id),
244                                     "/home/bonzo/develop/trunk/gcc/cp/parser.c",
245                                     30062, __FUNCTION__,
246                                     (IDENTIFIER_NODE)))->identifier.id.str);
247                 if (strcmp(p, "distribute") == 0) {
248                         if (!global_options.x_flag_openmp)
249                                 return cp_parser_omp_distribute(parser,
250                                                                 pragma_tok,
251                                                                 p_name, mask,
252                                                                 cclauses);
253                 }
254         }
257 static bool
258 cp_parser_omp_target(cp_parser * parser, cp_token * pragma_tok,
259                      enum pragma_context context)
261         if (context != pragma_stmt && context != pragma_compound) {
262                 tree id = cp_lexer_peek_token(parser->lexer)->u.value;
263                 const char *p =
264                     ((const char
265                       *)(tree_check((id),
266                                     "/home/bonzo/develop/trunk/gcc/cp/parser.c",
267                                     30201, __FUNCTION__,
268                                     (IDENTIFIER_NODE)))->identifier.id.str);
269                 if (strcmp(p, "teams") == 0) {
270                         tree cclauses[C_OMP_CLAUSE_SPLIT_COUNT];
271                         char p_name[sizeof
272                                     ("#pragma omp target teams distribute "
273                                      "parallel for simd")];
274                         if (!global_options.x_flag_openmp)
275                                 return cp_parser_omp_teams(parser, pragma_tok,
276                                                            p_name,
277                                                            ((((omp_clause_mask)
278                                                               1) <<
279                                                              PRAGMA_OMP_CLAUSE_DEVICE)
280                                                             |
281                                                             (((omp_clause_mask)
282                                                               1) <<
283                                                              PRAGMA_OMP_CLAUSE_MAP)
284                                                             |
285                                                             (((omp_clause_mask)
286                                                               1) <<
287                                                              PRAGMA_OMP_CLAUSE_IF)),
288                                                            cclauses);
289                 }
290         }
293 static void
294 cp_parser_omp_declare_reduction(cp_parser * parser, cp_token * pragma_tok,
295                                 enum pragma_context)
297         tree reduc_id = (tree) __null, orig_reduc_id = (tree) __null, type;
298         while (true) {
299                 type = cp_parser_type_id(parser);
300         }
303 static void
304 cp_parser_omp_declare(cp_parser * parser, cp_token * pragma_tok,
305                       enum pragma_context context)
307         if (cp_lexer_next_token_is(parser->lexer, CPP_NAME)) {
308                 tree id = cp_lexer_peek_token(parser->lexer)->u.value;
309                 const char *p =
310                     ((const char
311                       *)(tree_check((id),
312                                     "/home/bonzo/develop/trunk/gcc/cp/parser.c",
313                                     30883, __FUNCTION__,
314                                     (IDENTIFIER_NODE)))->identifier.id.str);
315                 if (strcmp(p, "simd") == 0) {
316                         cp_parser_omp_declare_reduction(parser, pragma_tok,
317                                                         context);
318                 }
319         }
322 static cp_parser *the_parser;
323 static bool cp_parser_pragma(cp_parser * parser, enum pragma_context context)
325         cp_token *pragma_tok;
326         unsigned int id;
327         switch (id) {
328         case PRAGMA_OMP_DECLARE_REDUCTION:
329                 cp_parser_omp_declare(parser, pragma_tok, context);
330         case PRAGMA_OMP_TARGET:
331                 return cp_parser_omp_target(parser, pragma_tok, context);
332         }
335 void c_parse_file(void)
337         cp_parser_translation_unit(the_parser);