2 Copyright (C) 2000-2017 Free Software Foundation, Inc.
3 Contributed by Andy Vaught
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 3, or (at your option) any later
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
23 #include "coretypes.h"
30 /* Current statement label. Zero means no statement label. Because new_st
31 can get wiped during statement matching, we have to keep it separate. */
33 gfc_st_label
*gfc_statement_label
;
35 static locus label_locus
;
36 static jmp_buf eof_buf
;
38 gfc_state_data
*gfc_state_stack
;
39 static bool last_was_use_stmt
= false;
41 /* TODO: Re-order functions to kill these forward decls. */
42 static void check_statement_label (gfc_statement
);
43 static void undo_new_statement (void);
44 static void reject_statement (void);
47 /* A sort of half-matching function. We try to match the word on the
48 input with the passed string. If this succeeds, we call the
49 keyword-dependent matching function that will match the rest of the
50 statement. For single keywords, the matching subroutine is
54 match_word (const char *str
, match (*subr
) (void), locus
*old_locus
)
69 gfc_current_locus
= *old_locus
;
77 /* Like match_word, but if str is matched, set a flag that it
80 match_word_omp_simd (const char *str
, match (*subr
) (void), locus
*old_locus
,
97 gfc_current_locus
= *old_locus
;
105 /* Load symbols from all USE statements encountered in this scoping unit. */
110 gfc_error_buffer old_error
;
112 gfc_push_error (&old_error
);
113 gfc_buffer_error (false);
115 gfc_buffer_error (true);
116 gfc_pop_error (&old_error
);
117 gfc_commit_symbols ();
118 gfc_warning_check ();
119 gfc_current_ns
->old_equiv
= gfc_current_ns
->equiv
;
120 gfc_current_ns
->old_data
= gfc_current_ns
->data
;
121 last_was_use_stmt
= false;
125 /* Figure out what the next statement is, (mostly) regardless of
126 proper ordering. The do...while(0) is there to prevent if/else
129 #define match(keyword, subr, st) \
131 if (match_word (keyword, subr, &old_locus) == MATCH_YES) \
134 undo_new_statement (); \
138 /* This is a specialist version of decode_statement that is used
139 for the specification statements in a function, whose
140 characteristics are deferred into the specification statements.
141 eg.: INTEGER (king = mykind) foo ()
142 USE mymodule, ONLY mykind.....
143 The KIND parameter needs a return after USE or IMPORT, whereas
144 derived type declarations can occur anywhere, up the executable
145 block. ST_GET_FCN_CHARACTERISTICS is returned when we have run
146 out of the correct kind of specification statements. */
148 decode_specification_statement (void)
154 if (gfc_match_eos () == MATCH_YES
)
157 old_locus
= gfc_current_locus
;
159 if (match_word ("use", gfc_match_use
, &old_locus
) == MATCH_YES
)
161 last_was_use_stmt
= true;
166 undo_new_statement ();
167 if (last_was_use_stmt
)
171 match ("import", gfc_match_import
, ST_IMPORT
);
173 if (gfc_current_block ()->result
->ts
.type
!= BT_DERIVED
)
176 match (NULL
, gfc_match_st_function
, ST_STATEMENT_FUNCTION
);
177 match (NULL
, gfc_match_data_decl
, ST_DATA_DECL
);
178 match (NULL
, gfc_match_enumerator_def
, ST_ENUMERATOR
);
180 /* General statement matching: Instead of testing every possible
181 statement, we eliminate most possibilities by peeking at the
184 c
= gfc_peek_ascii_char ();
189 match ("abstract% interface", gfc_match_abstract_interface
,
191 match ("allocatable", gfc_match_allocatable
, ST_ATTR_DECL
);
192 match ("asynchronous", gfc_match_asynchronous
, ST_ATTR_DECL
);
193 match ("automatic", gfc_match_automatic
, ST_ATTR_DECL
);
197 match (NULL
, gfc_match_bind_c_stmt
, ST_ATTR_DECL
);
201 match ("codimension", gfc_match_codimension
, ST_ATTR_DECL
);
202 match ("contiguous", gfc_match_contiguous
, ST_ATTR_DECL
);
206 match ("data", gfc_match_data
, ST_DATA
);
207 match ("dimension", gfc_match_dimension
, ST_ATTR_DECL
);
211 match ("enum , bind ( c )", gfc_match_enum
, ST_ENUM
);
212 match ("entry% ", gfc_match_entry
, ST_ENTRY
);
213 match ("equivalence", gfc_match_equivalence
, ST_EQUIVALENCE
);
214 match ("external", gfc_match_external
, ST_ATTR_DECL
);
218 match ("format", gfc_match_format
, ST_FORMAT
);
225 match ("implicit", gfc_match_implicit
, ST_IMPLICIT
);
226 match ("implicit% none", gfc_match_implicit_none
, ST_IMPLICIT_NONE
);
227 match ("interface", gfc_match_interface
, ST_INTERFACE
);
228 match ("intent", gfc_match_intent
, ST_ATTR_DECL
);
229 match ("intrinsic", gfc_match_intrinsic
, ST_ATTR_DECL
);
236 match ("namelist", gfc_match_namelist
, ST_NAMELIST
);
240 match ("optional", gfc_match_optional
, ST_ATTR_DECL
);
244 match ("parameter", gfc_match_parameter
, ST_PARAMETER
);
245 match ("pointer", gfc_match_pointer
, ST_ATTR_DECL
);
246 if (gfc_match_private (&st
) == MATCH_YES
)
248 match ("procedure", gfc_match_procedure
, ST_PROCEDURE
);
249 if (gfc_match_public (&st
) == MATCH_YES
)
251 match ("protected", gfc_match_protected
, ST_ATTR_DECL
);
258 match ("save", gfc_match_save
, ST_ATTR_DECL
);
259 match ("static", gfc_match_static
, ST_ATTR_DECL
);
260 match ("structure", gfc_match_structure_decl
, ST_STRUCTURE_DECL
);
264 match ("target", gfc_match_target
, ST_ATTR_DECL
);
265 match ("type", gfc_match_derived_decl
, ST_DERIVED_DECL
);
272 match ("value", gfc_match_value
, ST_ATTR_DECL
);
273 match ("volatile", gfc_match_volatile
, ST_ATTR_DECL
);
280 /* This is not a specification statement. See if any of the matchers
281 has stored an error message of some sort. */
285 gfc_buffer_error (false);
286 gfc_current_locus
= old_locus
;
288 return ST_GET_FCN_CHARACTERISTICS
;
291 static bool in_specification_block
;
293 /* This is the primary 'decode_statement'. */
295 decode_statement (void)
302 gfc_enforce_clean_symbol_state ();
304 gfc_clear_error (); /* Clear any pending errors. */
305 gfc_clear_warning (); /* Clear any pending warnings. */
307 gfc_matching_function
= false;
309 if (gfc_match_eos () == MATCH_YES
)
312 if (gfc_current_state () == COMP_FUNCTION
313 && gfc_current_block ()->result
->ts
.kind
== -1)
314 return decode_specification_statement ();
316 old_locus
= gfc_current_locus
;
318 c
= gfc_peek_ascii_char ();
322 if (match_word ("use", gfc_match_use
, &old_locus
) == MATCH_YES
)
324 last_was_use_stmt
= true;
328 undo_new_statement ();
331 if (last_was_use_stmt
)
334 /* Try matching a data declaration or function declaration. The
335 input "REALFUNCTIONA(N)" can mean several things in different
336 contexts, so it (and its relatives) get special treatment. */
338 if (gfc_current_state () == COMP_NONE
339 || gfc_current_state () == COMP_INTERFACE
340 || gfc_current_state () == COMP_CONTAINS
)
342 gfc_matching_function
= true;
343 m
= gfc_match_function_decl ();
346 else if (m
== MATCH_ERROR
)
350 gfc_current_locus
= old_locus
;
352 gfc_matching_function
= false;
354 /* Legacy parameter statements are ambiguous with assignments so try parameter
356 match ("parameter", gfc_match_parameter
, ST_PARAMETER
);
358 /* Match statements whose error messages are meant to be overwritten
359 by something better. */
361 match (NULL
, gfc_match_assignment
, ST_ASSIGNMENT
);
362 match (NULL
, gfc_match_pointer_assignment
, ST_POINTER_ASSIGNMENT
);
364 if (in_specification_block
)
366 m
= match_word (NULL
, gfc_match_st_function
, &old_locus
);
368 return ST_STATEMENT_FUNCTION
;
371 if (!(in_specification_block
&& m
== MATCH_ERROR
))
373 match (NULL
, gfc_match_ptr_fcn_assign
, ST_ASSIGNMENT
);
376 match (NULL
, gfc_match_data_decl
, ST_DATA_DECL
);
377 match (NULL
, gfc_match_enumerator_def
, ST_ENUMERATOR
);
379 /* Try to match a subroutine statement, which has the same optional
380 prefixes that functions can have. */
382 if (gfc_match_subroutine () == MATCH_YES
)
383 return ST_SUBROUTINE
;
385 gfc_current_locus
= old_locus
;
387 if (gfc_match_submod_proc () == MATCH_YES
)
389 if (gfc_new_block
->attr
.subroutine
)
390 return ST_SUBROUTINE
;
391 else if (gfc_new_block
->attr
.function
)
395 gfc_current_locus
= old_locus
;
397 /* Check for the IF, DO, SELECT, WHERE, FORALL, CRITICAL, BLOCK and ASSOCIATE
398 statements, which might begin with a block label. The match functions for
399 these statements are unusual in that their keyword is not seen before
400 the matcher is called. */
402 if (gfc_match_if (&st
) == MATCH_YES
)
405 gfc_current_locus
= old_locus
;
407 if (gfc_match_where (&st
) == MATCH_YES
)
410 gfc_current_locus
= old_locus
;
412 if (gfc_match_forall (&st
) == MATCH_YES
)
415 gfc_current_locus
= old_locus
;
417 /* Try to match TYPE as an alias for PRINT. */
418 if (gfc_match_type (&st
) == MATCH_YES
)
421 gfc_current_locus
= old_locus
;
423 match (NULL
, gfc_match_do
, ST_DO
);
424 match (NULL
, gfc_match_block
, ST_BLOCK
);
425 match (NULL
, gfc_match_associate
, ST_ASSOCIATE
);
426 match (NULL
, gfc_match_critical
, ST_CRITICAL
);
427 match (NULL
, gfc_match_select
, ST_SELECT_CASE
);
428 match (NULL
, gfc_match_select_type
, ST_SELECT_TYPE
);
430 /* General statement matching: Instead of testing every possible
431 statement, we eliminate most possibilities by peeking at the
437 match ("abstract% interface", gfc_match_abstract_interface
,
439 match ("allocate", gfc_match_allocate
, ST_ALLOCATE
);
440 match ("allocatable", gfc_match_allocatable
, ST_ATTR_DECL
);
441 match ("assign", gfc_match_assign
, ST_LABEL_ASSIGNMENT
);
442 match ("asynchronous", gfc_match_asynchronous
, ST_ATTR_DECL
);
443 match ("automatic", gfc_match_automatic
, ST_ATTR_DECL
);
447 match ("backspace", gfc_match_backspace
, ST_BACKSPACE
);
448 match ("block data", gfc_match_block_data
, ST_BLOCK_DATA
);
449 match (NULL
, gfc_match_bind_c_stmt
, ST_ATTR_DECL
);
453 match ("call", gfc_match_call
, ST_CALL
);
454 match ("close", gfc_match_close
, ST_CLOSE
);
455 match ("continue", gfc_match_continue
, ST_CONTINUE
);
456 match ("contiguous", gfc_match_contiguous
, ST_ATTR_DECL
);
457 match ("cycle", gfc_match_cycle
, ST_CYCLE
);
458 match ("case", gfc_match_case
, ST_CASE
);
459 match ("common", gfc_match_common
, ST_COMMON
);
460 match ("contains", gfc_match_eos
, ST_CONTAINS
);
461 match ("class", gfc_match_class_is
, ST_CLASS_IS
);
462 match ("codimension", gfc_match_codimension
, ST_ATTR_DECL
);
466 match ("deallocate", gfc_match_deallocate
, ST_DEALLOCATE
);
467 match ("data", gfc_match_data
, ST_DATA
);
468 match ("dimension", gfc_match_dimension
, ST_ATTR_DECL
);
472 match ("end file", gfc_match_endfile
, ST_END_FILE
);
473 match ("exit", gfc_match_exit
, ST_EXIT
);
474 match ("else", gfc_match_else
, ST_ELSE
);
475 match ("else where", gfc_match_elsewhere
, ST_ELSEWHERE
);
476 match ("else if", gfc_match_elseif
, ST_ELSEIF
);
477 match ("error stop", gfc_match_error_stop
, ST_ERROR_STOP
);
478 match ("enum , bind ( c )", gfc_match_enum
, ST_ENUM
);
480 if (gfc_match_end (&st
) == MATCH_YES
)
483 match ("entry% ", gfc_match_entry
, ST_ENTRY
);
484 match ("equivalence", gfc_match_equivalence
, ST_EQUIVALENCE
);
485 match ("external", gfc_match_external
, ST_ATTR_DECL
);
486 match ("event post", gfc_match_event_post
, ST_EVENT_POST
);
487 match ("event wait", gfc_match_event_wait
, ST_EVENT_WAIT
);
491 match ("fail image", gfc_match_fail_image
, ST_FAIL_IMAGE
);
492 match ("final", gfc_match_final_decl
, ST_FINAL
);
493 match ("flush", gfc_match_flush
, ST_FLUSH
);
494 match ("format", gfc_match_format
, ST_FORMAT
);
498 match ("generic", gfc_match_generic
, ST_GENERIC
);
499 match ("go to", gfc_match_goto
, ST_GOTO
);
503 match ("inquire", gfc_match_inquire
, ST_INQUIRE
);
504 match ("implicit", gfc_match_implicit
, ST_IMPLICIT
);
505 match ("implicit% none", gfc_match_implicit_none
, ST_IMPLICIT_NONE
);
506 match ("import", gfc_match_import
, ST_IMPORT
);
507 match ("interface", gfc_match_interface
, ST_INTERFACE
);
508 match ("intent", gfc_match_intent
, ST_ATTR_DECL
);
509 match ("intrinsic", gfc_match_intrinsic
, ST_ATTR_DECL
);
513 match ("lock", gfc_match_lock
, ST_LOCK
);
517 match ("map", gfc_match_map
, ST_MAP
);
518 match ("module% procedure", gfc_match_modproc
, ST_MODULE_PROC
);
519 match ("module", gfc_match_module
, ST_MODULE
);
523 match ("nullify", gfc_match_nullify
, ST_NULLIFY
);
524 match ("namelist", gfc_match_namelist
, ST_NAMELIST
);
528 match ("open", gfc_match_open
, ST_OPEN
);
529 match ("optional", gfc_match_optional
, ST_ATTR_DECL
);
533 match ("print", gfc_match_print
, ST_WRITE
);
534 match ("pause", gfc_match_pause
, ST_PAUSE
);
535 match ("pointer", gfc_match_pointer
, ST_ATTR_DECL
);
536 if (gfc_match_private (&st
) == MATCH_YES
)
538 match ("procedure", gfc_match_procedure
, ST_PROCEDURE
);
539 match ("program", gfc_match_program
, ST_PROGRAM
);
540 if (gfc_match_public (&st
) == MATCH_YES
)
542 match ("protected", gfc_match_protected
, ST_ATTR_DECL
);
546 match ("read", gfc_match_read
, ST_READ
);
547 match ("return", gfc_match_return
, ST_RETURN
);
548 match ("rewind", gfc_match_rewind
, ST_REWIND
);
552 match ("structure", gfc_match_structure_decl
, ST_STRUCTURE_DECL
);
553 match ("sequence", gfc_match_eos
, ST_SEQUENCE
);
554 match ("stop", gfc_match_stop
, ST_STOP
);
555 match ("save", gfc_match_save
, ST_ATTR_DECL
);
556 match ("static", gfc_match_static
, ST_ATTR_DECL
);
557 match ("submodule", gfc_match_submodule
, ST_SUBMODULE
);
558 match ("sync all", gfc_match_sync_all
, ST_SYNC_ALL
);
559 match ("sync images", gfc_match_sync_images
, ST_SYNC_IMAGES
);
560 match ("sync memory", gfc_match_sync_memory
, ST_SYNC_MEMORY
);
564 match ("target", gfc_match_target
, ST_ATTR_DECL
);
565 match ("type", gfc_match_derived_decl
, ST_DERIVED_DECL
);
566 match ("type is", gfc_match_type_is
, ST_TYPE_IS
);
570 match ("union", gfc_match_union
, ST_UNION
);
571 match ("unlock", gfc_match_unlock
, ST_UNLOCK
);
575 match ("value", gfc_match_value
, ST_ATTR_DECL
);
576 match ("volatile", gfc_match_volatile
, ST_ATTR_DECL
);
580 match ("wait", gfc_match_wait
, ST_WAIT
);
581 match ("write", gfc_match_write
, ST_WRITE
);
585 /* All else has failed, so give up. See if any of the matchers has
586 stored an error message of some sort. */
588 if (!gfc_error_check ())
589 gfc_error_now ("Unclassifiable statement at %C");
593 gfc_error_recovery ();
598 /* Like match and if spec_only, goto do_spec_only without actually
600 #define matcha(keyword, subr, st) \
602 if (spec_only && gfc_match (keyword) == MATCH_YES) \
604 else if (match_word (keyword, subr, &old_locus) \
608 undo_new_statement (); \
612 decode_oacc_directive (void)
616 bool spec_only
= false;
618 gfc_enforce_clean_symbol_state ();
620 gfc_clear_error (); /* Clear any pending errors. */
621 gfc_clear_warning (); /* Clear any pending warnings. */
625 gfc_error_now ("OpenACC directives at %C may not appear in PURE "
627 gfc_error_recovery ();
631 if (gfc_current_state () == COMP_FUNCTION
632 && gfc_current_block ()->result
->ts
.kind
== -1)
635 gfc_unset_implicit_pure (NULL
);
637 old_locus
= gfc_current_locus
;
639 /* General OpenACC directive matching: Instead of testing every possible
640 statement, we eliminate most possibilities by peeking at the
643 c
= gfc_peek_ascii_char ();
648 matcha ("atomic", gfc_match_oacc_atomic
, ST_OACC_ATOMIC
);
651 matcha ("cache", gfc_match_oacc_cache
, ST_OACC_CACHE
);
654 matcha ("data", gfc_match_oacc_data
, ST_OACC_DATA
);
655 match ("declare", gfc_match_oacc_declare
, ST_OACC_DECLARE
);
658 matcha ("end atomic", gfc_match_omp_eos
, ST_OACC_END_ATOMIC
);
659 matcha ("end data", gfc_match_omp_eos
, ST_OACC_END_DATA
);
660 matcha ("end host_data", gfc_match_omp_eos
, ST_OACC_END_HOST_DATA
);
661 matcha ("end kernels loop", gfc_match_omp_eos
, ST_OACC_END_KERNELS_LOOP
);
662 matcha ("end kernels", gfc_match_omp_eos
, ST_OACC_END_KERNELS
);
663 matcha ("end loop", gfc_match_omp_eos
, ST_OACC_END_LOOP
);
664 matcha ("end parallel loop", gfc_match_omp_eos
,
665 ST_OACC_END_PARALLEL_LOOP
);
666 matcha ("end parallel", gfc_match_omp_eos
, ST_OACC_END_PARALLEL
);
667 matcha ("enter data", gfc_match_oacc_enter_data
, ST_OACC_ENTER_DATA
);
668 matcha ("exit data", gfc_match_oacc_exit_data
, ST_OACC_EXIT_DATA
);
671 matcha ("host_data", gfc_match_oacc_host_data
, ST_OACC_HOST_DATA
);
674 matcha ("parallel loop", gfc_match_oacc_parallel_loop
,
675 ST_OACC_PARALLEL_LOOP
);
676 matcha ("parallel", gfc_match_oacc_parallel
, ST_OACC_PARALLEL
);
679 matcha ("kernels loop", gfc_match_oacc_kernels_loop
,
680 ST_OACC_KERNELS_LOOP
);
681 matcha ("kernels", gfc_match_oacc_kernels
, ST_OACC_KERNELS
);
684 matcha ("loop", gfc_match_oacc_loop
, ST_OACC_LOOP
);
687 match ("routine", gfc_match_oacc_routine
, ST_OACC_ROUTINE
);
690 matcha ("update", gfc_match_oacc_update
, ST_OACC_UPDATE
);
693 matcha ("wait", gfc_match_oacc_wait
, ST_OACC_WAIT
);
697 /* Directive not found or stored an error message.
698 Check and give up. */
700 if (gfc_error_check () == 0)
701 gfc_error_now ("Unclassifiable OpenACC directive at %C");
705 gfc_error_recovery ();
712 gfc_buffer_error (false);
713 gfc_current_locus
= old_locus
;
714 return ST_GET_FCN_CHARACTERISTICS
;
717 /* Like match, but set a flag simd_matched if keyword matched
718 and if spec_only, goto do_spec_only without actually matching. */
719 #define matchs(keyword, subr, st) \
721 if (spec_only && gfc_match (keyword) == MATCH_YES) \
723 if (match_word_omp_simd (keyword, subr, &old_locus, \
724 &simd_matched) == MATCH_YES) \
730 undo_new_statement (); \
733 /* Like match, but don't match anything if not -fopenmp
734 and if spec_only, goto do_spec_only without actually matching. */
735 #define matcho(keyword, subr, st) \
739 else if (spec_only && gfc_match (keyword) == MATCH_YES) \
741 else if (match_word (keyword, subr, &old_locus) \
748 undo_new_statement (); \
751 /* Like match, but set a flag simd_matched if keyword matched. */
752 #define matchds(keyword, subr, st) \
754 if (match_word_omp_simd (keyword, subr, &old_locus, \
755 &simd_matched) == MATCH_YES) \
761 undo_new_statement (); \
764 /* Like match, but don't match anything if not -fopenmp. */
765 #define matchdo(keyword, subr, st) \
769 else if (match_word (keyword, subr, &old_locus) \
776 undo_new_statement (); \
780 decode_omp_directive (void)
784 bool simd_matched
= false;
785 bool spec_only
= false;
786 gfc_statement ret
= ST_NONE
;
789 gfc_enforce_clean_symbol_state ();
791 gfc_clear_error (); /* Clear any pending errors. */
792 gfc_clear_warning (); /* Clear any pending warnings. */
794 if (gfc_current_state () == COMP_FUNCTION
795 && gfc_current_block ()->result
->ts
.kind
== -1)
798 old_locus
= gfc_current_locus
;
800 /* General OpenMP directive matching: Instead of testing every possible
801 statement, we eliminate most possibilities by peeking at the
804 c
= gfc_peek_ascii_char ();
806 /* match is for directives that should be recognized only if
807 -fopenmp, matchs for directives that should be recognized
808 if either -fopenmp or -fopenmp-simd.
809 Handle only the directives allowed in PURE/ELEMENTAL procedures
810 first (those also shall not turn off implicit pure). */
814 matchds ("declare simd", gfc_match_omp_declare_simd
,
815 ST_OMP_DECLARE_SIMD
);
816 matchdo ("declare target", gfc_match_omp_declare_target
,
817 ST_OMP_DECLARE_TARGET
);
820 matchs ("simd", gfc_match_omp_simd
, ST_OMP_SIMD
);
825 if (flag_openmp
&& gfc_pure (NULL
))
827 gfc_error_now ("OpenMP directives other than SIMD or DECLARE TARGET "
828 "at %C may not appear in PURE or ELEMENTAL procedures");
829 gfc_error_recovery ();
833 /* match is for directives that should be recognized only if
834 -fopenmp, matchs for directives that should be recognized
835 if either -fopenmp or -fopenmp-simd. */
839 matcho ("atomic", gfc_match_omp_atomic
, ST_OMP_ATOMIC
);
842 matcho ("barrier", gfc_match_omp_barrier
, ST_OMP_BARRIER
);
845 matcho ("cancellation% point", gfc_match_omp_cancellation_point
,
846 ST_OMP_CANCELLATION_POINT
);
847 matcho ("cancel", gfc_match_omp_cancel
, ST_OMP_CANCEL
);
848 matcho ("critical", gfc_match_omp_critical
, ST_OMP_CRITICAL
);
851 matchds ("declare reduction", gfc_match_omp_declare_reduction
,
852 ST_OMP_DECLARE_REDUCTION
);
853 matchs ("distribute parallel do simd",
854 gfc_match_omp_distribute_parallel_do_simd
,
855 ST_OMP_DISTRIBUTE_PARALLEL_DO_SIMD
);
856 matcho ("distribute parallel do", gfc_match_omp_distribute_parallel_do
,
857 ST_OMP_DISTRIBUTE_PARALLEL_DO
);
858 matchs ("distribute simd", gfc_match_omp_distribute_simd
,
859 ST_OMP_DISTRIBUTE_SIMD
);
860 matcho ("distribute", gfc_match_omp_distribute
, ST_OMP_DISTRIBUTE
);
861 matchs ("do simd", gfc_match_omp_do_simd
, ST_OMP_DO_SIMD
);
862 matcho ("do", gfc_match_omp_do
, ST_OMP_DO
);
865 matcho ("end atomic", gfc_match_omp_eos
, ST_OMP_END_ATOMIC
);
866 matcho ("end critical", gfc_match_omp_end_critical
, ST_OMP_END_CRITICAL
);
867 matchs ("end distribute parallel do simd", gfc_match_omp_eos
,
868 ST_OMP_END_DISTRIBUTE_PARALLEL_DO_SIMD
);
869 matcho ("end distribute parallel do", gfc_match_omp_eos
,
870 ST_OMP_END_DISTRIBUTE_PARALLEL_DO
);
871 matchs ("end distribute simd", gfc_match_omp_eos
,
872 ST_OMP_END_DISTRIBUTE_SIMD
);
873 matcho ("end distribute", gfc_match_omp_eos
, ST_OMP_END_DISTRIBUTE
);
874 matchs ("end do simd", gfc_match_omp_end_nowait
, ST_OMP_END_DO_SIMD
);
875 matcho ("end do", gfc_match_omp_end_nowait
, ST_OMP_END_DO
);
876 matchs ("end simd", gfc_match_omp_eos
, ST_OMP_END_SIMD
);
877 matcho ("end master", gfc_match_omp_eos
, ST_OMP_END_MASTER
);
878 matchs ("end ordered", gfc_match_omp_eos
, ST_OMP_END_ORDERED
);
879 matchs ("end parallel do simd", gfc_match_omp_eos
,
880 ST_OMP_END_PARALLEL_DO_SIMD
);
881 matcho ("end parallel do", gfc_match_omp_eos
, ST_OMP_END_PARALLEL_DO
);
882 matcho ("end parallel sections", gfc_match_omp_eos
,
883 ST_OMP_END_PARALLEL_SECTIONS
);
884 matcho ("end parallel workshare", gfc_match_omp_eos
,
885 ST_OMP_END_PARALLEL_WORKSHARE
);
886 matcho ("end parallel", gfc_match_omp_eos
, ST_OMP_END_PARALLEL
);
887 matcho ("end sections", gfc_match_omp_end_nowait
, ST_OMP_END_SECTIONS
);
888 matcho ("end single", gfc_match_omp_end_single
, ST_OMP_END_SINGLE
);
889 matcho ("end target data", gfc_match_omp_eos
, ST_OMP_END_TARGET_DATA
);
890 matchs ("end target parallel do simd", gfc_match_omp_eos
,
891 ST_OMP_END_TARGET_PARALLEL_DO_SIMD
);
892 matcho ("end target parallel do", gfc_match_omp_eos
,
893 ST_OMP_END_TARGET_PARALLEL_DO
);
894 matcho ("end target parallel", gfc_match_omp_eos
,
895 ST_OMP_END_TARGET_PARALLEL
);
896 matchs ("end target simd", gfc_match_omp_eos
, ST_OMP_END_TARGET_SIMD
);
897 matchs ("end target teams distribute parallel do simd",
899 ST_OMP_END_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD
);
900 matcho ("end target teams distribute parallel do", gfc_match_omp_eos
,
901 ST_OMP_END_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO
);
902 matchs ("end target teams distribute simd", gfc_match_omp_eos
,
903 ST_OMP_END_TARGET_TEAMS_DISTRIBUTE_SIMD
);
904 matcho ("end target teams distribute", gfc_match_omp_eos
,
905 ST_OMP_END_TARGET_TEAMS_DISTRIBUTE
);
906 matcho ("end target teams", gfc_match_omp_eos
, ST_OMP_END_TARGET_TEAMS
);
907 matcho ("end target", gfc_match_omp_eos
, ST_OMP_END_TARGET
);
908 matcho ("end taskgroup", gfc_match_omp_eos
, ST_OMP_END_TASKGROUP
);
909 matchs ("end taskloop simd", gfc_match_omp_eos
,
910 ST_OMP_END_TASKLOOP_SIMD
);
911 matcho ("end taskloop", gfc_match_omp_eos
, ST_OMP_END_TASKLOOP
);
912 matcho ("end task", gfc_match_omp_eos
, ST_OMP_END_TASK
);
913 matchs ("end teams distribute parallel do simd", gfc_match_omp_eos
,
914 ST_OMP_END_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD
);
915 matcho ("end teams distribute parallel do", gfc_match_omp_eos
,
916 ST_OMP_END_TEAMS_DISTRIBUTE_PARALLEL_DO
);
917 matchs ("end teams distribute simd", gfc_match_omp_eos
,
918 ST_OMP_END_TEAMS_DISTRIBUTE_SIMD
);
919 matcho ("end teams distribute", gfc_match_omp_eos
,
920 ST_OMP_END_TEAMS_DISTRIBUTE
);
921 matcho ("end teams", gfc_match_omp_eos
, ST_OMP_END_TEAMS
);
922 matcho ("end workshare", gfc_match_omp_end_nowait
,
923 ST_OMP_END_WORKSHARE
);
926 matcho ("flush", gfc_match_omp_flush
, ST_OMP_FLUSH
);
929 matcho ("master", gfc_match_omp_master
, ST_OMP_MASTER
);
932 if (gfc_match ("ordered depend (") == MATCH_YES
)
934 gfc_current_locus
= old_locus
;
937 matcho ("ordered", gfc_match_omp_ordered_depend
,
938 ST_OMP_ORDERED_DEPEND
);
941 matchs ("ordered", gfc_match_omp_ordered
, ST_OMP_ORDERED
);
944 matchs ("parallel do simd", gfc_match_omp_parallel_do_simd
,
945 ST_OMP_PARALLEL_DO_SIMD
);
946 matcho ("parallel do", gfc_match_omp_parallel_do
, ST_OMP_PARALLEL_DO
);
947 matcho ("parallel sections", gfc_match_omp_parallel_sections
,
948 ST_OMP_PARALLEL_SECTIONS
);
949 matcho ("parallel workshare", gfc_match_omp_parallel_workshare
,
950 ST_OMP_PARALLEL_WORKSHARE
);
951 matcho ("parallel", gfc_match_omp_parallel
, ST_OMP_PARALLEL
);
954 matcho ("sections", gfc_match_omp_sections
, ST_OMP_SECTIONS
);
955 matcho ("section", gfc_match_omp_eos
, ST_OMP_SECTION
);
956 matcho ("single", gfc_match_omp_single
, ST_OMP_SINGLE
);
959 matcho ("target data", gfc_match_omp_target_data
, ST_OMP_TARGET_DATA
);
960 matcho ("target enter data", gfc_match_omp_target_enter_data
,
961 ST_OMP_TARGET_ENTER_DATA
);
962 matcho ("target exit data", gfc_match_omp_target_exit_data
,
963 ST_OMP_TARGET_EXIT_DATA
);
964 matchs ("target parallel do simd", gfc_match_omp_target_parallel_do_simd
,
965 ST_OMP_TARGET_PARALLEL_DO_SIMD
);
966 matcho ("target parallel do", gfc_match_omp_target_parallel_do
,
967 ST_OMP_TARGET_PARALLEL_DO
);
968 matcho ("target parallel", gfc_match_omp_target_parallel
,
969 ST_OMP_TARGET_PARALLEL
);
970 matchs ("target simd", gfc_match_omp_target_simd
, ST_OMP_TARGET_SIMD
);
971 matchs ("target teams distribute parallel do simd",
972 gfc_match_omp_target_teams_distribute_parallel_do_simd
,
973 ST_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD
);
974 matcho ("target teams distribute parallel do",
975 gfc_match_omp_target_teams_distribute_parallel_do
,
976 ST_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO
);
977 matchs ("target teams distribute simd",
978 gfc_match_omp_target_teams_distribute_simd
,
979 ST_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD
);
980 matcho ("target teams distribute", gfc_match_omp_target_teams_distribute
,
981 ST_OMP_TARGET_TEAMS_DISTRIBUTE
);
982 matcho ("target teams", gfc_match_omp_target_teams
, ST_OMP_TARGET_TEAMS
);
983 matcho ("target update", gfc_match_omp_target_update
,
984 ST_OMP_TARGET_UPDATE
);
985 matcho ("target", gfc_match_omp_target
, ST_OMP_TARGET
);
986 matcho ("taskgroup", gfc_match_omp_taskgroup
, ST_OMP_TASKGROUP
);
987 matchs ("taskloop simd", gfc_match_omp_taskloop_simd
,
988 ST_OMP_TASKLOOP_SIMD
);
989 matcho ("taskloop", gfc_match_omp_taskloop
, ST_OMP_TASKLOOP
);
990 matcho ("taskwait", gfc_match_omp_taskwait
, ST_OMP_TASKWAIT
);
991 matcho ("taskyield", gfc_match_omp_taskyield
, ST_OMP_TASKYIELD
);
992 matcho ("task", gfc_match_omp_task
, ST_OMP_TASK
);
993 matchs ("teams distribute parallel do simd",
994 gfc_match_omp_teams_distribute_parallel_do_simd
,
995 ST_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD
);
996 matcho ("teams distribute parallel do",
997 gfc_match_omp_teams_distribute_parallel_do
,
998 ST_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO
);
999 matchs ("teams distribute simd", gfc_match_omp_teams_distribute_simd
,
1000 ST_OMP_TEAMS_DISTRIBUTE_SIMD
);
1001 matcho ("teams distribute", gfc_match_omp_teams_distribute
,
1002 ST_OMP_TEAMS_DISTRIBUTE
);
1003 matcho ("teams", gfc_match_omp_teams
, ST_OMP_TEAMS
);
1004 matchdo ("threadprivate", gfc_match_omp_threadprivate
,
1005 ST_OMP_THREADPRIVATE
);
1008 matcho ("workshare", gfc_match_omp_workshare
, ST_OMP_WORKSHARE
);
1012 /* All else has failed, so give up. See if any of the matchers has
1013 stored an error message of some sort. Don't error out if
1014 not -fopenmp and simd_matched is false, i.e. if a directive other
1015 than one marked with match has been seen. */
1017 if (flag_openmp
|| simd_matched
)
1019 if (!gfc_error_check ())
1020 gfc_error_now ("Unclassifiable OpenMP directive at %C");
1023 reject_statement ();
1025 gfc_error_recovery ();
1032 gfc_unset_implicit_pure (NULL
);
1034 if (!flag_openmp
&& gfc_pure (NULL
))
1036 gfc_error_now ("OpenMP directives other than SIMD or DECLARE TARGET "
1037 "at %C may not appear in PURE or ELEMENTAL "
1039 reject_statement ();
1040 gfc_error_recovery ();
1047 reject_statement ();
1049 gfc_buffer_error (false);
1050 gfc_current_locus
= old_locus
;
1051 return ST_GET_FCN_CHARACTERISTICS
;
1054 static gfc_statement
1055 decode_gcc_attribute (void)
1059 gfc_enforce_clean_symbol_state ();
1061 gfc_clear_error (); /* Clear any pending errors. */
1062 gfc_clear_warning (); /* Clear any pending warnings. */
1063 old_locus
= gfc_current_locus
;
1065 match ("attributes", gfc_match_gcc_attributes
, ST_ATTR_DECL
);
1067 /* All else has failed, so give up. See if any of the matchers has
1068 stored an error message of some sort. */
1070 if (!gfc_error_check ())
1071 gfc_error_now ("Unclassifiable GCC directive at %C");
1073 reject_statement ();
1075 gfc_error_recovery ();
1082 /* Assert next length characters to be equal to token in free form. */
1085 verify_token_free (const char* token
, int length
, bool last_was_use_stmt
)
1090 c
= gfc_next_ascii_char ();
1091 for (i
= 0; i
< length
; i
++, c
= gfc_next_ascii_char ())
1092 gcc_assert (c
== token
[i
]);
1094 gcc_assert (gfc_is_whitespace(c
));
1095 gfc_gobble_whitespace ();
1096 if (last_was_use_stmt
)
1100 /* Get the next statement in free form source. */
1102 static gfc_statement
1109 at_bol
= gfc_at_bol ();
1110 gfc_gobble_whitespace ();
1112 c
= gfc_peek_ascii_char ();
1118 /* Found a statement label? */
1119 m
= gfc_match_st_label (&gfc_statement_label
);
1121 d
= gfc_peek_ascii_char ();
1122 if (m
!= MATCH_YES
|| !gfc_is_whitespace (d
))
1124 gfc_match_small_literal_int (&i
, &cnt
);
1127 gfc_error_now ("Too many digits in statement label at %C");
1130 gfc_error_now ("Zero is not a valid statement label at %C");
1133 c
= gfc_next_ascii_char ();
1136 if (!gfc_is_whitespace (c
))
1137 gfc_error_now ("Non-numeric character in statement label at %C");
1143 label_locus
= gfc_current_locus
;
1145 gfc_gobble_whitespace ();
1147 if (at_bol
&& gfc_peek_ascii_char () == ';')
1149 gfc_error_now ("Semicolon at %C needs to be preceded by "
1151 gfc_next_ascii_char (); /* Eat up the semicolon. */
1155 if (gfc_match_eos () == MATCH_YES
)
1156 gfc_error_now ("Statement label without statement at %L",
1162 /* Comments have already been skipped by the time we get here,
1163 except for GCC attributes and OpenMP/OpenACC directives. */
1165 gfc_next_ascii_char (); /* Eat up the exclamation sign. */
1166 c
= gfc_peek_ascii_char ();
1172 c
= gfc_next_ascii_char ();
1173 for (i
= 0; i
< 4; i
++, c
= gfc_next_ascii_char ())
1174 gcc_assert (c
== "gcc$"[i
]);
1176 gfc_gobble_whitespace ();
1177 return decode_gcc_attribute ();
1182 /* Since both OpenMP and OpenACC directives starts with
1183 !$ character sequence, we must check all flags combinations */
1184 if ((flag_openmp
|| flag_openmp_simd
)
1187 verify_token_free ("$omp", 4, last_was_use_stmt
);
1188 return decode_omp_directive ();
1190 else if ((flag_openmp
|| flag_openmp_simd
)
1193 gfc_next_ascii_char (); /* Eat up dollar character */
1194 c
= gfc_peek_ascii_char ();
1198 verify_token_free ("omp", 3, last_was_use_stmt
);
1199 return decode_omp_directive ();
1203 verify_token_free ("acc", 3, last_was_use_stmt
);
1204 return decode_oacc_directive ();
1207 else if (flag_openacc
)
1209 verify_token_free ("$acc", 4, last_was_use_stmt
);
1210 return decode_oacc_directive ();
1216 if (at_bol
&& c
== ';')
1218 if (!(gfc_option
.allow_std
& GFC_STD_F2008
))
1219 gfc_error_now ("Fortran 2008: Semicolon at %C without preceding "
1221 gfc_next_ascii_char (); /* Eat up the semicolon. */
1225 return decode_statement ();
1228 /* Assert next length characters to be equal to token in fixed form. */
1231 verify_token_fixed (const char *token
, int length
, bool last_was_use_stmt
)
1234 char c
= gfc_next_char_literal (NONSTRING
);
1236 for (i
= 0; i
< length
; i
++, c
= gfc_next_char_literal (NONSTRING
))
1237 gcc_assert ((char) gfc_wide_tolower (c
) == token
[i
]);
1239 if (c
!= ' ' && c
!= '0')
1241 gfc_buffer_error (false);
1242 gfc_error ("Bad continuation line at %C");
1245 if (last_was_use_stmt
)
1251 /* Get the next statement in fixed-form source. */
1253 static gfc_statement
1256 int label
, digit_flag
, i
;
1261 return decode_statement ();
1263 /* Skip past the current label field, parsing a statement label if
1264 one is there. This is a weird number parser, since the number is
1265 contained within five columns and can have any kind of embedded
1266 spaces. We also check for characters that make the rest of the
1272 for (i
= 0; i
< 5; i
++)
1274 c
= gfc_next_char_literal (NONSTRING
);
1291 label
= label
* 10 + ((unsigned char) c
- '0');
1292 label_locus
= gfc_current_locus
;
1296 /* Comments have already been skipped by the time we get
1297 here, except for GCC attributes and OpenMP directives. */
1300 c
= gfc_next_char_literal (NONSTRING
);
1302 if (TOLOWER (c
) == 'g')
1304 for (i
= 0; i
< 4; i
++, c
= gfc_next_char_literal (NONSTRING
))
1305 gcc_assert (TOLOWER (c
) == "gcc$"[i
]);
1307 return decode_gcc_attribute ();
1311 if ((flag_openmp
|| flag_openmp_simd
)
1314 if (!verify_token_fixed ("omp", 3, last_was_use_stmt
))
1316 return decode_omp_directive ();
1318 else if ((flag_openmp
|| flag_openmp_simd
)
1321 c
= gfc_next_char_literal(NONSTRING
);
1322 if (c
== 'o' || c
== 'O')
1324 if (!verify_token_fixed ("mp", 2, last_was_use_stmt
))
1326 return decode_omp_directive ();
1328 else if (c
== 'a' || c
== 'A')
1330 if (!verify_token_fixed ("cc", 2, last_was_use_stmt
))
1332 return decode_oacc_directive ();
1335 else if (flag_openacc
)
1337 if (!verify_token_fixed ("acc", 3, last_was_use_stmt
))
1339 return decode_oacc_directive ();
1344 /* Comments have already been skipped by the time we get
1345 here so don't bother checking for them. */
1348 gfc_buffer_error (false);
1349 gfc_error ("Non-numeric character in statement label at %C");
1357 gfc_warning_now (0, "Zero is not a valid statement label at %C");
1360 /* We've found a valid statement label. */
1361 gfc_statement_label
= gfc_get_st_label (label
);
1365 /* Since this line starts a statement, it cannot be a continuation
1366 of a previous statement. If we see something here besides a
1367 space or zero, it must be a bad continuation line. */
1369 c
= gfc_next_char_literal (NONSTRING
);
1373 if (c
!= ' ' && c
!= '0')
1375 gfc_buffer_error (false);
1376 gfc_error ("Bad continuation line at %C");
1380 /* Now that we've taken care of the statement label columns, we have
1381 to make sure that the first nonblank character is not a '!'. If
1382 it is, the rest of the line is a comment. */
1386 loc
= gfc_current_locus
;
1387 c
= gfc_next_char_literal (NONSTRING
);
1389 while (gfc_is_whitespace (c
));
1393 gfc_current_locus
= loc
;
1398 gfc_error_now ("Semicolon at %C needs to be preceded by statement");
1399 else if (!(gfc_option
.allow_std
& GFC_STD_F2008
))
1400 gfc_error_now ("Fortran 2008: Semicolon at %C without preceding "
1405 if (gfc_match_eos () == MATCH_YES
)
1408 /* At this point, we've got a nonblank statement to parse. */
1409 return decode_statement ();
1413 gfc_error_now ("Statement label without statement at %L", &label_locus
);
1415 gfc_current_locus
.lb
->truncated
= 0;
1416 gfc_advance_line ();
1421 /* Return the next non-ST_NONE statement to the caller. We also worry
1422 about including files and the ends of include files at this stage. */
1424 static gfc_statement
1425 next_statement (void)
1430 gfc_enforce_clean_symbol_state ();
1432 gfc_new_block
= NULL
;
1434 gfc_current_ns
->old_equiv
= gfc_current_ns
->equiv
;
1435 gfc_current_ns
->old_data
= gfc_current_ns
->data
;
1438 gfc_statement_label
= NULL
;
1439 gfc_buffer_error (true);
1442 gfc_advance_line ();
1444 gfc_skip_comments ();
1452 if (gfc_define_undef_line ())
1455 old_locus
= gfc_current_locus
;
1457 st
= (gfc_current_form
== FORM_FIXED
) ? next_fixed () : next_free ();
1463 gfc_buffer_error (false);
1465 if (st
== ST_GET_FCN_CHARACTERISTICS
)
1467 if (gfc_statement_label
!= NULL
)
1469 gfc_free_st_label (gfc_statement_label
);
1470 gfc_statement_label
= NULL
;
1472 gfc_current_locus
= old_locus
;
1476 check_statement_label (st
);
1482 /****************************** Parser ***********************************/
1484 /* The parser subroutines are of type 'try' that fail if the file ends
1487 /* Macros that expand to case-labels for various classes of
1488 statements. Start with executable statements that directly do
1491 #define case_executable case ST_ALLOCATE: case ST_BACKSPACE: case ST_CALL: \
1492 case ST_CLOSE: case ST_CONTINUE: case ST_DEALLOCATE: case ST_END_FILE: \
1493 case ST_GOTO: case ST_INQUIRE: case ST_NULLIFY: case ST_OPEN: \
1494 case ST_READ: case ST_RETURN: case ST_REWIND: case ST_SIMPLE_IF: \
1495 case ST_PAUSE: case ST_STOP: case ST_WAIT: case ST_WRITE: \
1496 case ST_POINTER_ASSIGNMENT: case ST_EXIT: case ST_CYCLE: \
1497 case ST_ASSIGNMENT: case ST_ARITHMETIC_IF: case ST_WHERE: case ST_FORALL: \
1498 case ST_LABEL_ASSIGNMENT: case ST_FLUSH: case ST_OMP_FLUSH: \
1499 case ST_OMP_BARRIER: case ST_OMP_TASKWAIT: case ST_OMP_TASKYIELD: \
1500 case ST_OMP_CANCEL: case ST_OMP_CANCELLATION_POINT: \
1501 case ST_OMP_TARGET_UPDATE: case ST_OMP_TARGET_ENTER_DATA: \
1502 case ST_OMP_TARGET_EXIT_DATA: case ST_OMP_ORDERED_DEPEND: \
1503 case ST_ERROR_STOP: case ST_SYNC_ALL: \
1504 case ST_SYNC_IMAGES: case ST_SYNC_MEMORY: case ST_LOCK: case ST_UNLOCK: \
1505 case ST_EVENT_POST: case ST_EVENT_WAIT: case ST_FAIL_IMAGE: \
1506 case ST_OACC_UPDATE: case ST_OACC_WAIT: case ST_OACC_CACHE: \
1507 case ST_OACC_ENTER_DATA: case ST_OACC_EXIT_DATA
1509 /* Statements that mark other executable statements. */
1511 #define case_exec_markers case ST_DO: case ST_FORALL_BLOCK: \
1512 case ST_IF_BLOCK: case ST_BLOCK: case ST_ASSOCIATE: \
1513 case ST_WHERE_BLOCK: case ST_SELECT_CASE: case ST_SELECT_TYPE: \
1514 case ST_OMP_PARALLEL: \
1515 case ST_OMP_PARALLEL_SECTIONS: case ST_OMP_SECTIONS: case ST_OMP_ORDERED: \
1516 case ST_OMP_CRITICAL: case ST_OMP_MASTER: case ST_OMP_SINGLE: \
1517 case ST_OMP_DO: case ST_OMP_PARALLEL_DO: case ST_OMP_ATOMIC: \
1518 case ST_OMP_WORKSHARE: case ST_OMP_PARALLEL_WORKSHARE: \
1519 case ST_OMP_TASK: case ST_OMP_TASKGROUP: case ST_OMP_SIMD: \
1520 case ST_OMP_DO_SIMD: case ST_OMP_PARALLEL_DO_SIMD: case ST_OMP_TARGET: \
1521 case ST_OMP_TARGET_DATA: case ST_OMP_TARGET_TEAMS: \
1522 case ST_OMP_TARGET_TEAMS_DISTRIBUTE: \
1523 case ST_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD: \
1524 case ST_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO: \
1525 case ST_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD: \
1526 case ST_OMP_TEAMS: case ST_OMP_TEAMS_DISTRIBUTE: \
1527 case ST_OMP_TEAMS_DISTRIBUTE_SIMD: \
1528 case ST_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO: \
1529 case ST_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD: case ST_OMP_DISTRIBUTE: \
1530 case ST_OMP_DISTRIBUTE_SIMD: case ST_OMP_DISTRIBUTE_PARALLEL_DO: \
1531 case ST_OMP_DISTRIBUTE_PARALLEL_DO_SIMD: case ST_OMP_TARGET_PARALLEL: \
1532 case ST_OMP_TARGET_PARALLEL_DO: case ST_OMP_TARGET_PARALLEL_DO_SIMD: \
1533 case ST_OMP_TARGET_SIMD: case ST_OMP_TASKLOOP: case ST_OMP_TASKLOOP_SIMD: \
1535 case ST_OACC_PARALLEL_LOOP: case ST_OACC_PARALLEL: case ST_OACC_KERNELS: \
1536 case ST_OACC_DATA: case ST_OACC_HOST_DATA: case ST_OACC_LOOP: \
1537 case ST_OACC_KERNELS_LOOP: case ST_OACC_ATOMIC
1539 /* Declaration statements */
1541 #define case_decl case ST_ATTR_DECL: case ST_COMMON: case ST_DATA_DECL: \
1542 case ST_EQUIVALENCE: case ST_NAMELIST: case ST_STATEMENT_FUNCTION: \
1543 case ST_TYPE: case ST_INTERFACE: case ST_PROCEDURE: case ST_OACC_ROUTINE: \
1544 case ST_OACC_DECLARE
1546 /* OpenMP declaration statements. */
1548 #define case_omp_decl case ST_OMP_THREADPRIVATE: case ST_OMP_DECLARE_SIMD: \
1549 case ST_OMP_DECLARE_TARGET: case ST_OMP_DECLARE_REDUCTION
1551 /* Block end statements. Errors associated with interchanging these
1552 are detected in gfc_match_end(). */
1554 #define case_end case ST_END_BLOCK_DATA: case ST_END_FUNCTION: \
1555 case ST_END_PROGRAM: case ST_END_SUBROUTINE: \
1556 case ST_END_BLOCK: case ST_END_ASSOCIATE
1559 /* Push a new state onto the stack. */
1562 push_state (gfc_state_data
*p
, gfc_compile_state new_state
, gfc_symbol
*sym
)
1564 p
->state
= new_state
;
1565 p
->previous
= gfc_state_stack
;
1567 p
->head
= p
->tail
= NULL
;
1568 p
->do_variable
= NULL
;
1569 if (p
->state
!= COMP_DO
&& p
->state
!= COMP_DO_CONCURRENT
)
1570 p
->ext
.oacc_declare_clauses
= NULL
;
1572 /* If this the state of a construct like BLOCK, DO or IF, the corresponding
1573 construct statement was accepted right before pushing the state. Thus,
1574 the construct's gfc_code is available as tail of the parent state. */
1575 gcc_assert (gfc_state_stack
);
1576 p
->construct
= gfc_state_stack
->tail
;
1578 gfc_state_stack
= p
;
1582 /* Pop the current state. */
1586 gfc_state_stack
= gfc_state_stack
->previous
;
1590 /* Try to find the given state in the state stack. */
1593 gfc_find_state (gfc_compile_state state
)
1597 for (p
= gfc_state_stack
; p
; p
= p
->previous
)
1598 if (p
->state
== state
)
1601 return (p
== NULL
) ? false : true;
1605 /* Starts a new level in the statement list. */
1608 new_level (gfc_code
*q
)
1612 p
= q
->block
= gfc_get_code (EXEC_NOP
);
1614 gfc_state_stack
->head
= gfc_state_stack
->tail
= p
;
1620 /* Add the current new_st code structure and adds it to the current
1621 program unit. As a side-effect, it zeroes the new_st. */
1624 add_statement (void)
1628 p
= XCNEW (gfc_code
);
1631 p
->loc
= gfc_current_locus
;
1633 if (gfc_state_stack
->head
== NULL
)
1634 gfc_state_stack
->head
= p
;
1636 gfc_state_stack
->tail
->next
= p
;
1638 while (p
->next
!= NULL
)
1641 gfc_state_stack
->tail
= p
;
1643 gfc_clear_new_st ();
1649 /* Frees everything associated with the current statement. */
1652 undo_new_statement (void)
1654 gfc_free_statements (new_st
.block
);
1655 gfc_free_statements (new_st
.next
);
1656 gfc_free_statement (&new_st
);
1657 gfc_clear_new_st ();
1661 /* If the current statement has a statement label, make sure that it
1662 is allowed to, or should have one. */
1665 check_statement_label (gfc_statement st
)
1669 if (gfc_statement_label
== NULL
)
1671 if (st
== ST_FORMAT
)
1672 gfc_error ("FORMAT statement at %L does not have a statement label",
1679 case ST_END_PROGRAM
:
1680 case ST_END_FUNCTION
:
1681 case ST_END_SUBROUTINE
:
1685 case ST_END_CRITICAL
:
1687 case ST_END_ASSOCIATE
:
1690 if (st
== ST_ENDDO
|| st
== ST_CONTINUE
)
1691 type
= ST_LABEL_DO_TARGET
;
1693 type
= ST_LABEL_TARGET
;
1697 type
= ST_LABEL_FORMAT
;
1700 /* Statement labels are not restricted from appearing on a
1701 particular line. However, there are plenty of situations
1702 where the resulting label can't be referenced. */
1705 type
= ST_LABEL_BAD_TARGET
;
1709 gfc_define_st_label (gfc_statement_label
, type
, &label_locus
);
1711 new_st
.here
= gfc_statement_label
;
1715 /* Figures out what the enclosing program unit is. This will be a
1716 function, subroutine, program, block data or module. */
1719 gfc_enclosing_unit (gfc_compile_state
* result
)
1723 for (p
= gfc_state_stack
; p
; p
= p
->previous
)
1724 if (p
->state
== COMP_FUNCTION
|| p
->state
== COMP_SUBROUTINE
1725 || p
->state
== COMP_MODULE
|| p
->state
== COMP_SUBMODULE
1726 || p
->state
== COMP_BLOCK_DATA
|| p
->state
== COMP_PROGRAM
)
1735 *result
= COMP_PROGRAM
;
1740 /* Translate a statement enum to a string. */
1743 gfc_ascii_statement (gfc_statement st
)
1749 case ST_ARITHMETIC_IF
:
1750 p
= _("arithmetic IF");
1759 p
= _("attribute declaration");
1795 p
= _("data declaration");
1809 case ST_STRUCTURE_DECL
:
1812 case ST_DERIVED_DECL
:
1813 p
= _("derived type declaration");
1836 case ST_END_ASSOCIATE
:
1837 p
= "END ASSOCIATE";
1842 case ST_END_BLOCK_DATA
:
1843 p
= "END BLOCK DATA";
1845 case ST_END_CRITICAL
:
1857 case ST_END_FUNCTION
:
1863 case ST_END_INTERFACE
:
1864 p
= "END INTERFACE";
1869 case ST_END_SUBMODULE
:
1870 p
= "END SUBMODULE";
1872 case ST_END_PROGRAM
:
1878 case ST_END_SUBROUTINE
:
1879 p
= "END SUBROUTINE";
1884 case ST_END_STRUCTURE
:
1885 p
= "END STRUCTURE";
1899 case ST_EQUIVALENCE
:
1911 case ST_FORALL_BLOCK
: /* Fall through */
1933 case ST_IMPLICIT_NONE
:
1934 p
= "IMPLICIT NONE";
1936 case ST_IMPLIED_ENDDO
:
1937 p
= _("implied END DO");
1969 case ST_MODULE_PROC
:
1970 p
= "MODULE PROCEDURE";
2002 case ST_SYNC_IMAGES
:
2005 case ST_SYNC_MEMORY
:
2020 case ST_WHERE_BLOCK
: /* Fall through */
2031 p
= _("assignment");
2033 case ST_POINTER_ASSIGNMENT
:
2034 p
= _("pointer assignment");
2036 case ST_SELECT_CASE
:
2039 case ST_SELECT_TYPE
:
2054 case ST_STATEMENT_FUNCTION
:
2055 p
= "STATEMENT FUNCTION";
2057 case ST_LABEL_ASSIGNMENT
:
2058 p
= "LABEL ASSIGNMENT";
2061 p
= "ENUM DEFINITION";
2064 p
= "ENUMERATOR DEFINITION";
2069 case ST_OACC_PARALLEL_LOOP
:
2070 p
= "!$ACC PARALLEL LOOP";
2072 case ST_OACC_END_PARALLEL_LOOP
:
2073 p
= "!$ACC END PARALLEL LOOP";
2075 case ST_OACC_PARALLEL
:
2076 p
= "!$ACC PARALLEL";
2078 case ST_OACC_END_PARALLEL
:
2079 p
= "!$ACC END PARALLEL";
2081 case ST_OACC_KERNELS
:
2082 p
= "!$ACC KERNELS";
2084 case ST_OACC_END_KERNELS
:
2085 p
= "!$ACC END KERNELS";
2087 case ST_OACC_KERNELS_LOOP
:
2088 p
= "!$ACC KERNELS LOOP";
2090 case ST_OACC_END_KERNELS_LOOP
:
2091 p
= "!$ACC END KERNELS LOOP";
2096 case ST_OACC_END_DATA
:
2097 p
= "!$ACC END DATA";
2099 case ST_OACC_HOST_DATA
:
2100 p
= "!$ACC HOST_DATA";
2102 case ST_OACC_END_HOST_DATA
:
2103 p
= "!$ACC END HOST_DATA";
2108 case ST_OACC_END_LOOP
:
2109 p
= "!$ACC END LOOP";
2111 case ST_OACC_DECLARE
:
2112 p
= "!$ACC DECLARE";
2114 case ST_OACC_UPDATE
:
2123 case ST_OACC_ENTER_DATA
:
2124 p
= "!$ACC ENTER DATA";
2126 case ST_OACC_EXIT_DATA
:
2127 p
= "!$ACC EXIT DATA";
2129 case ST_OACC_ROUTINE
:
2130 p
= "!$ACC ROUTINE";
2132 case ST_OACC_ATOMIC
:
2135 case ST_OACC_END_ATOMIC
:
2136 p
= "!$ACC END ATOMIC";
2141 case ST_OMP_BARRIER
:
2142 p
= "!$OMP BARRIER";
2147 case ST_OMP_CANCELLATION_POINT
:
2148 p
= "!$OMP CANCELLATION POINT";
2150 case ST_OMP_CRITICAL
:
2151 p
= "!$OMP CRITICAL";
2153 case ST_OMP_DECLARE_REDUCTION
:
2154 p
= "!$OMP DECLARE REDUCTION";
2156 case ST_OMP_DECLARE_SIMD
:
2157 p
= "!$OMP DECLARE SIMD";
2159 case ST_OMP_DECLARE_TARGET
:
2160 p
= "!$OMP DECLARE TARGET";
2162 case ST_OMP_DISTRIBUTE
:
2163 p
= "!$OMP DISTRIBUTE";
2165 case ST_OMP_DISTRIBUTE_PARALLEL_DO
:
2166 p
= "!$OMP DISTRIBUTE PARALLEL DO";
2168 case ST_OMP_DISTRIBUTE_PARALLEL_DO_SIMD
:
2169 p
= "!$OMP DISTRIBUTE PARALLEL DO SIMD";
2171 case ST_OMP_DISTRIBUTE_SIMD
:
2172 p
= "!$OMP DISTRIBUTE SIMD";
2177 case ST_OMP_DO_SIMD
:
2178 p
= "!$OMP DO SIMD";
2180 case ST_OMP_END_ATOMIC
:
2181 p
= "!$OMP END ATOMIC";
2183 case ST_OMP_END_CRITICAL
:
2184 p
= "!$OMP END CRITICAL";
2186 case ST_OMP_END_DISTRIBUTE
:
2187 p
= "!$OMP END DISTRIBUTE";
2189 case ST_OMP_END_DISTRIBUTE_PARALLEL_DO
:
2190 p
= "!$OMP END DISTRIBUTE PARALLEL DO";
2192 case ST_OMP_END_DISTRIBUTE_PARALLEL_DO_SIMD
:
2193 p
= "!$OMP END DISTRIBUTE PARALLEL DO SIMD";
2195 case ST_OMP_END_DISTRIBUTE_SIMD
:
2196 p
= "!$OMP END DISTRIBUTE SIMD";
2201 case ST_OMP_END_DO_SIMD
:
2202 p
= "!$OMP END DO SIMD";
2204 case ST_OMP_END_SIMD
:
2205 p
= "!$OMP END SIMD";
2207 case ST_OMP_END_MASTER
:
2208 p
= "!$OMP END MASTER";
2210 case ST_OMP_END_ORDERED
:
2211 p
= "!$OMP END ORDERED";
2213 case ST_OMP_END_PARALLEL
:
2214 p
= "!$OMP END PARALLEL";
2216 case ST_OMP_END_PARALLEL_DO
:
2217 p
= "!$OMP END PARALLEL DO";
2219 case ST_OMP_END_PARALLEL_DO_SIMD
:
2220 p
= "!$OMP END PARALLEL DO SIMD";
2222 case ST_OMP_END_PARALLEL_SECTIONS
:
2223 p
= "!$OMP END PARALLEL SECTIONS";
2225 case ST_OMP_END_PARALLEL_WORKSHARE
:
2226 p
= "!$OMP END PARALLEL WORKSHARE";
2228 case ST_OMP_END_SECTIONS
:
2229 p
= "!$OMP END SECTIONS";
2231 case ST_OMP_END_SINGLE
:
2232 p
= "!$OMP END SINGLE";
2234 case ST_OMP_END_TASK
:
2235 p
= "!$OMP END TASK";
2237 case ST_OMP_END_TARGET
:
2238 p
= "!$OMP END TARGET";
2240 case ST_OMP_END_TARGET_DATA
:
2241 p
= "!$OMP END TARGET DATA";
2243 case ST_OMP_END_TARGET_PARALLEL
:
2244 p
= "!$OMP END TARGET PARALLEL";
2246 case ST_OMP_END_TARGET_PARALLEL_DO
:
2247 p
= "!$OMP END TARGET PARALLEL DO";
2249 case ST_OMP_END_TARGET_PARALLEL_DO_SIMD
:
2250 p
= "!$OMP END TARGET PARALLEL DO SIMD";
2252 case ST_OMP_END_TARGET_SIMD
:
2253 p
= "!$OMP END TARGET SIMD";
2255 case ST_OMP_END_TARGET_TEAMS
:
2256 p
= "!$OMP END TARGET TEAMS";
2258 case ST_OMP_END_TARGET_TEAMS_DISTRIBUTE
:
2259 p
= "!$OMP END TARGET TEAMS DISTRIBUTE";
2261 case ST_OMP_END_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO
:
2262 p
= "!$OMP END TARGET TEAMS DISTRIBUTE PARALLEL DO";
2264 case ST_OMP_END_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD
:
2265 p
= "!$OMP END TARGET TEAMS DISTRIBUTE PARALLEL DO SIMD";
2267 case ST_OMP_END_TARGET_TEAMS_DISTRIBUTE_SIMD
:
2268 p
= "!$OMP END TARGET TEAMS DISTRIBUTE SIMD";
2270 case ST_OMP_END_TASKGROUP
:
2271 p
= "!$OMP END TASKGROUP";
2273 case ST_OMP_END_TASKLOOP
:
2274 p
= "!$OMP END TASKLOOP";
2276 case ST_OMP_END_TASKLOOP_SIMD
:
2277 p
= "!$OMP END TASKLOOP SIMD";
2279 case ST_OMP_END_TEAMS
:
2280 p
= "!$OMP END TEAMS";
2282 case ST_OMP_END_TEAMS_DISTRIBUTE
:
2283 p
= "!$OMP END TEAMS DISTRIBUTE";
2285 case ST_OMP_END_TEAMS_DISTRIBUTE_PARALLEL_DO
:
2286 p
= "!$OMP END TEAMS DISTRIBUTE PARALLEL DO";
2288 case ST_OMP_END_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD
:
2289 p
= "!$OMP END TEAMS DISTRIBUTE PARALLEL DO SIMD";
2291 case ST_OMP_END_TEAMS_DISTRIBUTE_SIMD
:
2292 p
= "!$OMP END TEAMS DISTRIBUTE SIMD";
2294 case ST_OMP_END_WORKSHARE
:
2295 p
= "!$OMP END WORKSHARE";
2303 case ST_OMP_ORDERED
:
2304 case ST_OMP_ORDERED_DEPEND
:
2305 p
= "!$OMP ORDERED";
2307 case ST_OMP_PARALLEL
:
2308 p
= "!$OMP PARALLEL";
2310 case ST_OMP_PARALLEL_DO
:
2311 p
= "!$OMP PARALLEL DO";
2313 case ST_OMP_PARALLEL_DO_SIMD
:
2314 p
= "!$OMP PARALLEL DO SIMD";
2316 case ST_OMP_PARALLEL_SECTIONS
:
2317 p
= "!$OMP PARALLEL SECTIONS";
2319 case ST_OMP_PARALLEL_WORKSHARE
:
2320 p
= "!$OMP PARALLEL WORKSHARE";
2322 case ST_OMP_SECTIONS
:
2323 p
= "!$OMP SECTIONS";
2325 case ST_OMP_SECTION
:
2326 p
= "!$OMP SECTION";
2337 case ST_OMP_TARGET_DATA
:
2338 p
= "!$OMP TARGET DATA";
2340 case ST_OMP_TARGET_ENTER_DATA
:
2341 p
= "!$OMP TARGET ENTER DATA";
2343 case ST_OMP_TARGET_EXIT_DATA
:
2344 p
= "!$OMP TARGET EXIT DATA";
2346 case ST_OMP_TARGET_PARALLEL
:
2347 p
= "!$OMP TARGET PARALLEL";
2349 case ST_OMP_TARGET_PARALLEL_DO
:
2350 p
= "!$OMP TARGET PARALLEL DO";
2352 case ST_OMP_TARGET_PARALLEL_DO_SIMD
:
2353 p
= "!$OMP TARGET PARALLEL DO SIMD";
2355 case ST_OMP_TARGET_SIMD
:
2356 p
= "!$OMP TARGET SIMD";
2358 case ST_OMP_TARGET_TEAMS
:
2359 p
= "!$OMP TARGET TEAMS";
2361 case ST_OMP_TARGET_TEAMS_DISTRIBUTE
:
2362 p
= "!$OMP TARGET TEAMS DISTRIBUTE";
2364 case ST_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO
:
2365 p
= "!$OMP TARGET TEAMS DISTRIBUTE PARALLEL DO";
2367 case ST_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD
:
2368 p
= "!$OMP TARGET TEAMS DISTRIBUTE PARALLEL DO SIMD";
2370 case ST_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD
:
2371 p
= "!$OMP TARGET TEAMS DISTRIBUTE SIMD";
2373 case ST_OMP_TARGET_UPDATE
:
2374 p
= "!$OMP TARGET UPDATE";
2379 case ST_OMP_TASKGROUP
:
2380 p
= "!$OMP TASKGROUP";
2382 case ST_OMP_TASKLOOP
:
2383 p
= "!$OMP TASKLOOP";
2385 case ST_OMP_TASKLOOP_SIMD
:
2386 p
= "!$OMP TASKLOOP SIMD";
2388 case ST_OMP_TASKWAIT
:
2389 p
= "!$OMP TASKWAIT";
2391 case ST_OMP_TASKYIELD
:
2392 p
= "!$OMP TASKYIELD";
2397 case ST_OMP_TEAMS_DISTRIBUTE
:
2398 p
= "!$OMP TEAMS DISTRIBUTE";
2400 case ST_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO
:
2401 p
= "!$OMP TEAMS DISTRIBUTE PARALLEL DO";
2403 case ST_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD
:
2404 p
= "!$OMP TEAMS DISTRIBUTE PARALLEL DO SIMD";
2406 case ST_OMP_TEAMS_DISTRIBUTE_SIMD
:
2407 p
= "!$OMP TEAMS DISTRIBUTE SIMD";
2409 case ST_OMP_THREADPRIVATE
:
2410 p
= "!$OMP THREADPRIVATE";
2412 case ST_OMP_WORKSHARE
:
2413 p
= "!$OMP WORKSHARE";
2416 gfc_internal_error ("gfc_ascii_statement(): Bad statement code");
2423 /* Create a symbol for the main program and assign it to ns->proc_name. */
2426 main_program_symbol (gfc_namespace
*ns
, const char *name
)
2428 gfc_symbol
*main_program
;
2429 symbol_attribute attr
;
2431 gfc_get_symbol (name
, ns
, &main_program
);
2432 gfc_clear_attr (&attr
);
2433 attr
.flavor
= FL_PROGRAM
;
2434 attr
.proc
= PROC_UNKNOWN
;
2435 attr
.subroutine
= 1;
2436 attr
.access
= ACCESS_PUBLIC
;
2437 attr
.is_main_program
= 1;
2438 main_program
->attr
= attr
;
2439 main_program
->declared_at
= gfc_current_locus
;
2440 ns
->proc_name
= main_program
;
2441 gfc_commit_symbols ();
2445 /* Do whatever is necessary to accept the last statement. */
2448 accept_statement (gfc_statement st
)
2452 case ST_IMPLICIT_NONE
:
2460 gfc_current_ns
->proc_name
= gfc_new_block
;
2463 /* If the statement is the end of a block, lay down a special code
2464 that allows a branch to the end of the block from within the
2465 construct. IF and SELECT are treated differently from DO
2466 (where EXEC_NOP is added inside the loop) for two
2468 1. END DO has a meaning in the sense that after a GOTO to
2469 it, the loop counter must be increased.
2470 2. IF blocks and SELECT blocks can consist of multiple
2471 parallel blocks (IF ... ELSE IF ... ELSE ... END IF).
2472 Putting the label before the END IF would make the jump
2473 from, say, the ELSE IF block to the END IF illegal. */
2477 case ST_END_CRITICAL
:
2478 if (gfc_statement_label
!= NULL
)
2480 new_st
.op
= EXEC_END_NESTED_BLOCK
;
2485 /* In the case of BLOCK and ASSOCIATE blocks, there cannot be more than
2486 one parallel block. Thus, we add the special code to the nested block
2487 itself, instead of the parent one. */
2489 case ST_END_ASSOCIATE
:
2490 if (gfc_statement_label
!= NULL
)
2492 new_st
.op
= EXEC_END_BLOCK
;
2497 /* The end-of-program unit statements do not get the special
2498 marker and require a statement of some sort if they are a
2501 case ST_END_PROGRAM
:
2502 case ST_END_FUNCTION
:
2503 case ST_END_SUBROUTINE
:
2504 if (gfc_statement_label
!= NULL
)
2506 new_st
.op
= EXEC_RETURN
;
2511 new_st
.op
= EXEC_END_PROCEDURE
;
2527 gfc_commit_symbols ();
2528 gfc_warning_check ();
2529 gfc_clear_new_st ();
2533 /* Undo anything tentative that has been built for the current statement,
2534 except if a gfc_charlen structure has been added to current namespace's
2535 list of gfc_charlen structure. */
2538 reject_statement (void)
2540 gfc_free_equiv_until (gfc_current_ns
->equiv
, gfc_current_ns
->old_equiv
);
2541 gfc_current_ns
->equiv
= gfc_current_ns
->old_equiv
;
2543 gfc_reject_data (gfc_current_ns
);
2545 gfc_new_block
= NULL
;
2546 gfc_undo_symbols ();
2547 gfc_clear_warning ();
2548 undo_new_statement ();
2552 /* Generic complaint about an out of order statement. We also do
2553 whatever is necessary to clean up. */
2556 unexpected_statement (gfc_statement st
)
2558 gfc_error ("Unexpected %s statement at %C", gfc_ascii_statement (st
));
2560 reject_statement ();
2564 /* Given the next statement seen by the matcher, make sure that it is
2565 in proper order with the last. This subroutine is initialized by
2566 calling it with an argument of ST_NONE. If there is a problem, we
2567 issue an error and return false. Otherwise we return true.
2569 Individual parsers need to verify that the statements seen are
2570 valid before calling here, i.e., ENTRY statements are not allowed in
2571 INTERFACE blocks. The following diagram is taken from the standard:
2573 +---------------------------------------+
2574 | program subroutine function module |
2575 +---------------------------------------+
2577 +---------------------------------------+
2579 +---------------------------------------+
2581 | +-----------+------------------+
2582 | | parameter | implicit |
2583 | +-----------+------------------+
2584 | format | | derived type |
2585 | entry | parameter | interface |
2586 | | data | specification |
2587 | | | statement func |
2588 | +-----------+------------------+
2589 | | data | executable |
2590 +--------+-----------+------------------+
2592 +---------------------------------------+
2593 | internal module/subprogram |
2594 +---------------------------------------+
2596 +---------------------------------------+
2605 ORDER_IMPLICIT_NONE
,
2613 enum state_order state
;
2614 gfc_statement last_statement
;
2620 verify_st_order (st_state
*p
, gfc_statement st
, bool silent
)
2626 p
->state
= ORDER_START
;
2630 if (p
->state
> ORDER_USE
)
2632 p
->state
= ORDER_USE
;
2636 if (p
->state
> ORDER_IMPORT
)
2638 p
->state
= ORDER_IMPORT
;
2641 case ST_IMPLICIT_NONE
:
2642 if (p
->state
> ORDER_IMPLICIT
)
2645 /* The '>' sign cannot be a '>=', because a FORMAT or ENTRY
2646 statement disqualifies a USE but not an IMPLICIT NONE.
2647 Duplicate IMPLICIT NONEs are caught when the implicit types
2650 p
->state
= ORDER_IMPLICIT_NONE
;
2654 if (p
->state
> ORDER_IMPLICIT
)
2656 p
->state
= ORDER_IMPLICIT
;
2661 if (p
->state
< ORDER_IMPLICIT_NONE
)
2662 p
->state
= ORDER_IMPLICIT_NONE
;
2666 if (p
->state
>= ORDER_EXEC
)
2668 if (p
->state
< ORDER_IMPLICIT
)
2669 p
->state
= ORDER_IMPLICIT
;
2673 if (p
->state
< ORDER_SPEC
)
2674 p
->state
= ORDER_SPEC
;
2679 case ST_STRUCTURE_DECL
:
2680 case ST_DERIVED_DECL
:
2682 if (p
->state
>= ORDER_EXEC
)
2684 if (p
->state
< ORDER_SPEC
)
2685 p
->state
= ORDER_SPEC
;
2689 /* The OpenMP directives have to be somewhere in the specification
2690 part, but there are no further requirements on their ordering.
2691 Thus don't adjust p->state, just ignore them. */
2692 if (p
->state
>= ORDER_EXEC
)
2698 if (p
->state
< ORDER_EXEC
)
2699 p
->state
= ORDER_EXEC
;
2706 /* All is well, record the statement in case we need it next time. */
2707 p
->where
= gfc_current_locus
;
2708 p
->last_statement
= st
;
2713 gfc_error ("%s statement at %C cannot follow %s statement at %L",
2714 gfc_ascii_statement (st
),
2715 gfc_ascii_statement (p
->last_statement
), &p
->where
);
2721 /* Handle an unexpected end of file. This is a show-stopper... */
2723 static void unexpected_eof (void) ATTRIBUTE_NORETURN
;
2726 unexpected_eof (void)
2730 gfc_error ("Unexpected end of file in %qs", gfc_source_file
);
2732 /* Memory cleanup. Move to "second to last". */
2733 for (p
= gfc_state_stack
; p
&& p
->previous
&& p
->previous
->previous
;
2736 gfc_current_ns
->code
= (p
&& p
->previous
) ? p
->head
: NULL
;
2739 longjmp (eof_buf
, 1);
2741 /* Avoids build error on systems where longjmp is not declared noreturn. */
2746 /* Parse the CONTAINS section of a derived type definition. */
2748 gfc_access gfc_typebound_default_access
;
2751 parse_derived_contains (void)
2754 bool seen_private
= false;
2755 bool seen_comps
= false;
2756 bool error_flag
= false;
2759 gcc_assert (gfc_current_state () == COMP_DERIVED
);
2760 gcc_assert (gfc_current_block ());
2762 /* Derived-types with SEQUENCE and/or BIND(C) must not have a CONTAINS
2764 if (gfc_current_block ()->attr
.sequence
)
2765 gfc_error ("Derived-type %qs with SEQUENCE must not have a CONTAINS"
2766 " section at %C", gfc_current_block ()->name
);
2767 if (gfc_current_block ()->attr
.is_bind_c
)
2768 gfc_error ("Derived-type %qs with BIND(C) must not have a CONTAINS"
2769 " section at %C", gfc_current_block ()->name
);
2771 accept_statement (ST_CONTAINS
);
2772 push_state (&s
, COMP_DERIVED_CONTAINS
, NULL
);
2774 gfc_typebound_default_access
= ACCESS_PUBLIC
;
2780 st
= next_statement ();
2788 gfc_error ("Components in TYPE at %C must precede CONTAINS");
2792 if (!gfc_notify_std (GFC_STD_F2003
, "Type-bound procedure at %C"))
2795 accept_statement (ST_PROCEDURE
);
2800 if (!gfc_notify_std (GFC_STD_F2003
, "GENERIC binding at %C"))
2803 accept_statement (ST_GENERIC
);
2808 if (!gfc_notify_std (GFC_STD_F2003
, "FINAL procedure declaration"
2812 accept_statement (ST_FINAL
);
2820 && (!gfc_notify_std(GFC_STD_F2008
, "Derived type definition "
2821 "at %C with empty CONTAINS section")))
2824 /* ST_END_TYPE is accepted by parse_derived after return. */
2828 if (!gfc_find_state (COMP_MODULE
))
2830 gfc_error ("PRIVATE statement in TYPE at %C must be inside "
2837 gfc_error ("PRIVATE statement at %C must precede procedure"
2844 gfc_error ("Duplicate PRIVATE statement at %C");
2848 accept_statement (ST_PRIVATE
);
2849 gfc_typebound_default_access
= ACCESS_PRIVATE
;
2850 seen_private
= true;
2854 gfc_error ("SEQUENCE statement at %C must precede CONTAINS");
2858 gfc_error ("Already inside a CONTAINS block at %C");
2862 unexpected_statement (st
);
2870 reject_statement ();
2874 gcc_assert (gfc_current_state () == COMP_DERIVED
);
2880 /* Set attributes for the parent symbol based on the attributes of a component
2881 and raise errors if conflicting attributes are found for the component. */
2884 check_component (gfc_symbol
*sym
, gfc_component
*c
, gfc_component
**lockp
,
2885 gfc_component
**eventp
)
2887 bool coarray
, lock_type
, event_type
, allocatable
, pointer
;
2888 coarray
= lock_type
= event_type
= allocatable
= pointer
= false;
2889 gfc_component
*lock_comp
= NULL
, *event_comp
= NULL
;
2891 if (lockp
) lock_comp
= *lockp
;
2892 if (eventp
) event_comp
= *eventp
;
2894 /* Look for allocatable components. */
2895 if (c
->attr
.allocatable
2896 || (c
->ts
.type
== BT_CLASS
&& c
->attr
.class_ok
2897 && CLASS_DATA (c
)->attr
.allocatable
)
2898 || (c
->ts
.type
== BT_DERIVED
&& !c
->attr
.pointer
2899 && c
->ts
.u
.derived
->attr
.alloc_comp
))
2902 sym
->attr
.alloc_comp
= 1;
2905 /* Look for pointer components. */
2907 || (c
->ts
.type
== BT_CLASS
&& c
->attr
.class_ok
2908 && CLASS_DATA (c
)->attr
.class_pointer
)
2909 || (c
->ts
.type
== BT_DERIVED
&& c
->ts
.u
.derived
->attr
.pointer_comp
))
2912 sym
->attr
.pointer_comp
= 1;
2915 /* Look for procedure pointer components. */
2916 if (c
->attr
.proc_pointer
2917 || (c
->ts
.type
== BT_DERIVED
2918 && c
->ts
.u
.derived
->attr
.proc_pointer_comp
))
2919 sym
->attr
.proc_pointer_comp
= 1;
2921 /* Looking for coarray components. */
2922 if (c
->attr
.codimension
2923 || (c
->ts
.type
== BT_CLASS
&& c
->attr
.class_ok
2924 && CLASS_DATA (c
)->attr
.codimension
))
2927 sym
->attr
.coarray_comp
= 1;
2930 if (c
->ts
.type
== BT_DERIVED
&& c
->ts
.u
.derived
->attr
.coarray_comp
2931 && !c
->attr
.pointer
)
2934 sym
->attr
.coarray_comp
= 1;
2937 /* Looking for lock_type components. */
2938 if ((c
->ts
.type
== BT_DERIVED
2939 && c
->ts
.u
.derived
->from_intmod
== INTMOD_ISO_FORTRAN_ENV
2940 && c
->ts
.u
.derived
->intmod_sym_id
== ISOFORTRAN_LOCK_TYPE
)
2941 || (c
->ts
.type
== BT_CLASS
&& c
->attr
.class_ok
2942 && CLASS_DATA (c
)->ts
.u
.derived
->from_intmod
2943 == INTMOD_ISO_FORTRAN_ENV
2944 && CLASS_DATA (c
)->ts
.u
.derived
->intmod_sym_id
2945 == ISOFORTRAN_LOCK_TYPE
)
2946 || (c
->ts
.type
== BT_DERIVED
&& c
->ts
.u
.derived
->attr
.lock_comp
2947 && !allocatable
&& !pointer
))
2951 sym
->attr
.lock_comp
= 1;
2954 /* Looking for event_type components. */
2955 if ((c
->ts
.type
== BT_DERIVED
2956 && c
->ts
.u
.derived
->from_intmod
== INTMOD_ISO_FORTRAN_ENV
2957 && c
->ts
.u
.derived
->intmod_sym_id
== ISOFORTRAN_EVENT_TYPE
)
2958 || (c
->ts
.type
== BT_CLASS
&& c
->attr
.class_ok
2959 && CLASS_DATA (c
)->ts
.u
.derived
->from_intmod
2960 == INTMOD_ISO_FORTRAN_ENV
2961 && CLASS_DATA (c
)->ts
.u
.derived
->intmod_sym_id
2962 == ISOFORTRAN_EVENT_TYPE
)
2963 || (c
->ts
.type
== BT_DERIVED
&& c
->ts
.u
.derived
->attr
.event_comp
2964 && !allocatable
&& !pointer
))
2968 sym
->attr
.event_comp
= 1;
2971 /* Check for F2008, C1302 - and recall that pointers may not be coarrays
2972 (5.3.14) and that subobjects of coarray are coarray themselves (2.4.7),
2973 unless there are nondirect [allocatable or pointer] components
2974 involved (cf. 1.3.33.1 and 1.3.33.3). */
2976 if (pointer
&& !coarray
&& lock_type
)
2977 gfc_error ("Component %s at %L of type LOCK_TYPE must have a "
2978 "codimension or be a subcomponent of a coarray, "
2979 "which is not possible as the component has the "
2980 "pointer attribute", c
->name
, &c
->loc
);
2981 else if (pointer
&& !coarray
&& c
->ts
.type
== BT_DERIVED
2982 && c
->ts
.u
.derived
->attr
.lock_comp
)
2983 gfc_error ("Pointer component %s at %L has a noncoarray subcomponent "
2984 "of type LOCK_TYPE, which must have a codimension or be a "
2985 "subcomponent of a coarray", c
->name
, &c
->loc
);
2987 if (lock_type
&& allocatable
&& !coarray
)
2988 gfc_error ("Allocatable component %s at %L of type LOCK_TYPE must have "
2989 "a codimension", c
->name
, &c
->loc
);
2990 else if (lock_type
&& allocatable
&& c
->ts
.type
== BT_DERIVED
2991 && c
->ts
.u
.derived
->attr
.lock_comp
)
2992 gfc_error ("Allocatable component %s at %L must have a codimension as "
2993 "it has a noncoarray subcomponent of type LOCK_TYPE",
2996 if (sym
->attr
.coarray_comp
&& !coarray
&& lock_type
)
2997 gfc_error ("Noncoarray component %s at %L of type LOCK_TYPE or with "
2998 "subcomponent of type LOCK_TYPE must have a codimension or "
2999 "be a subcomponent of a coarray. (Variables of type %s may "
3000 "not have a codimension as already a coarray "
3001 "subcomponent exists)", c
->name
, &c
->loc
, sym
->name
);
3003 if (sym
->attr
.lock_comp
&& coarray
&& !lock_type
)
3004 gfc_error ("Noncoarray component %s at %L of type LOCK_TYPE or with "
3005 "subcomponent of type LOCK_TYPE must have a codimension or "
3006 "be a subcomponent of a coarray. (Variables of type %s may "
3007 "not have a codimension as %s at %L has a codimension or a "
3008 "coarray subcomponent)", lock_comp
->name
, &lock_comp
->loc
,
3009 sym
->name
, c
->name
, &c
->loc
);
3011 /* Similarly for EVENT TYPE. */
3013 if (pointer
&& !coarray
&& event_type
)
3014 gfc_error ("Component %s at %L of type EVENT_TYPE must have a "
3015 "codimension or be a subcomponent of a coarray, "
3016 "which is not possible as the component has the "
3017 "pointer attribute", c
->name
, &c
->loc
);
3018 else if (pointer
&& !coarray
&& c
->ts
.type
== BT_DERIVED
3019 && c
->ts
.u
.derived
->attr
.event_comp
)
3020 gfc_error ("Pointer component %s at %L has a noncoarray subcomponent "
3021 "of type EVENT_TYPE, which must have a codimension or be a "
3022 "subcomponent of a coarray", c
->name
, &c
->loc
);
3024 if (event_type
&& allocatable
&& !coarray
)
3025 gfc_error ("Allocatable component %s at %L of type EVENT_TYPE must have "
3026 "a codimension", c
->name
, &c
->loc
);
3027 else if (event_type
&& allocatable
&& c
->ts
.type
== BT_DERIVED
3028 && c
->ts
.u
.derived
->attr
.event_comp
)
3029 gfc_error ("Allocatable component %s at %L must have a codimension as "
3030 "it has a noncoarray subcomponent of type EVENT_TYPE",
3033 if (sym
->attr
.coarray_comp
&& !coarray
&& event_type
)
3034 gfc_error ("Noncoarray component %s at %L of type EVENT_TYPE or with "
3035 "subcomponent of type EVENT_TYPE must have a codimension or "
3036 "be a subcomponent of a coarray. (Variables of type %s may "
3037 "not have a codimension as already a coarray "
3038 "subcomponent exists)", c
->name
, &c
->loc
, sym
->name
);
3040 if (sym
->attr
.event_comp
&& coarray
&& !event_type
)
3041 gfc_error ("Noncoarray component %s at %L of type EVENT_TYPE or with "
3042 "subcomponent of type EVENT_TYPE must have a codimension or "
3043 "be a subcomponent of a coarray. (Variables of type %s may "
3044 "not have a codimension as %s at %L has a codimension or a "
3045 "coarray subcomponent)", event_comp
->name
, &event_comp
->loc
,
3046 sym
->name
, c
->name
, &c
->loc
);
3048 /* Look for private components. */
3049 if (sym
->component_access
== ACCESS_PRIVATE
3050 || c
->attr
.access
== ACCESS_PRIVATE
3051 || (c
->ts
.type
== BT_DERIVED
&& c
->ts
.u
.derived
->attr
.private_comp
))
3052 sym
->attr
.private_comp
= 1;
3054 if (lockp
) *lockp
= lock_comp
;
3055 if (eventp
) *eventp
= event_comp
;
3059 static void parse_struct_map (gfc_statement
);
3061 /* Parse a union component definition within a structure definition. */
3069 gfc_component
*c
, *lock_comp
= NULL
, *event_comp
= NULL
;
3072 accept_statement(ST_UNION
);
3073 push_state (&s
, COMP_UNION
, gfc_new_block
);
3080 st
= next_statement ();
3081 /* Only MAP declarations valid within a union. */
3088 accept_statement (ST_MAP
);
3089 parse_struct_map (ST_MAP
);
3090 /* Add a component to the union for each map. */
3091 if (!gfc_add_component (un
, gfc_new_block
->name
, &c
))
3093 gfc_internal_error ("failed to create map component '%s'",
3094 gfc_new_block
->name
);
3095 reject_statement ();
3098 c
->ts
.type
= BT_DERIVED
;
3099 c
->ts
.u
.derived
= gfc_new_block
;
3100 /* Normally components get their initialization expressions when they
3101 are created in decl.c (build_struct) so we can look through the
3102 flat component list for initializers during resolution. Unions and
3103 maps create components along with their type definitions so we
3104 have to generate initializers here. */
3105 c
->initializer
= gfc_default_initializer (&c
->ts
);
3110 accept_statement (ST_END_UNION
);
3114 unexpected_statement (st
);
3119 for (c
= un
->components
; c
; c
= c
->next
)
3120 check_component (un
, c
, &lock_comp
, &event_comp
);
3122 /* Add the union as a component in its parent structure. */
3124 if (!gfc_add_component (gfc_current_block (), un
->name
, &c
))
3126 gfc_internal_error ("failed to create union component '%s'", un
->name
);
3127 reject_statement ();
3130 c
->ts
.type
= BT_UNION
;
3131 c
->ts
.u
.derived
= un
;
3132 c
->initializer
= gfc_default_initializer (&c
->ts
);
3134 un
->attr
.zero_comp
= un
->components
== NULL
;
3138 /* Parse a STRUCTURE or MAP. */
3141 parse_struct_map (gfc_statement block
)
3147 gfc_component
*c
, *lock_comp
= NULL
, *event_comp
= NULL
;
3148 gfc_compile_state comp
;
3151 if (block
== ST_STRUCTURE_DECL
)
3153 comp
= COMP_STRUCTURE
;
3154 ends
= ST_END_STRUCTURE
;
3158 gcc_assert (block
== ST_MAP
);
3163 accept_statement(block
);
3164 push_state (&s
, comp
, gfc_new_block
);
3166 gfc_new_block
->component_access
= ACCESS_PUBLIC
;
3169 while (compiling_type
)
3171 st
= next_statement ();
3177 /* Nested structure declarations will be captured as ST_DATA_DECL. */
3178 case ST_STRUCTURE_DECL
:
3179 /* Let a more specific error make it to decode_statement(). */
3180 if (gfc_error_check () == 0)
3181 gfc_error ("Syntax error in nested structure declaration at %C");
3182 reject_statement ();
3183 /* Skip the rest of this statement. */
3184 gfc_error_recovery ();
3188 accept_statement (ST_UNION
);
3193 /* The data declaration was a nested/ad-hoc STRUCTURE field. */
3194 accept_statement (ST_DATA_DECL
);
3195 if (gfc_new_block
&& gfc_new_block
!= gfc_current_block ()
3196 && gfc_new_block
->attr
.flavor
== FL_STRUCT
)
3197 parse_struct_map (ST_STRUCTURE_DECL
);
3200 case ST_END_STRUCTURE
:
3204 accept_statement (st
);
3208 unexpected_statement (st
);
3212 unexpected_statement (st
);
3217 /* Validate each component. */
3218 sym
= gfc_current_block ();
3219 for (c
= sym
->components
; c
; c
= c
->next
)
3220 check_component (sym
, c
, &lock_comp
, &event_comp
);
3222 sym
->attr
.zero_comp
= (sym
->components
== NULL
);
3224 /* Allow parse_union to find this structure to add to its list of maps. */
3225 if (block
== ST_MAP
)
3226 gfc_new_block
= gfc_current_block ();
3232 /* Parse a derived type. */
3235 parse_derived (void)
3237 int compiling_type
, seen_private
, seen_sequence
, seen_component
;
3241 gfc_component
*c
, *lock_comp
= NULL
, *event_comp
= NULL
;
3243 accept_statement (ST_DERIVED_DECL
);
3244 push_state (&s
, COMP_DERIVED
, gfc_new_block
);
3246 gfc_new_block
->component_access
= ACCESS_PUBLIC
;
3253 while (compiling_type
)
3255 st
= next_statement ();
3263 accept_statement (st
);
3268 gfc_error ("FINAL declaration at %C must be inside CONTAINS");
3275 if (!seen_component
)
3276 gfc_notify_std (GFC_STD_F2003
, "Derived type "
3277 "definition at %C without components");
3279 accept_statement (ST_END_TYPE
);
3283 if (!gfc_find_state (COMP_MODULE
))
3285 gfc_error ("PRIVATE statement in TYPE at %C must be inside "
3292 gfc_error ("PRIVATE statement at %C must precede "
3293 "structure components");
3298 gfc_error ("Duplicate PRIVATE statement at %C");
3300 s
.sym
->component_access
= ACCESS_PRIVATE
;
3302 accept_statement (ST_PRIVATE
);
3309 gfc_error ("SEQUENCE statement at %C must precede "
3310 "structure components");
3314 if (gfc_current_block ()->attr
.sequence
)
3315 gfc_warning (0, "SEQUENCE attribute at %C already specified in "
3320 gfc_error ("Duplicate SEQUENCE statement at %C");
3324 gfc_add_sequence (&gfc_current_block ()->attr
,
3325 gfc_current_block ()->name
, NULL
);
3329 gfc_notify_std (GFC_STD_F2003
,
3330 "CONTAINS block in derived type"
3331 " definition at %C");
3333 accept_statement (ST_CONTAINS
);
3334 parse_derived_contains ();
3338 unexpected_statement (st
);
3343 /* need to verify that all fields of the derived type are
3344 * interoperable with C if the type is declared to be bind(c)
3346 sym
= gfc_current_block ();
3347 for (c
= sym
->components
; c
; c
= c
->next
)
3348 check_component (sym
, c
, &lock_comp
, &event_comp
);
3350 if (!seen_component
)
3351 sym
->attr
.zero_comp
= 1;
3357 /* Parse an ENUM. */
3365 int seen_enumerator
= 0;
3367 push_state (&s
, COMP_ENUM
, gfc_new_block
);
3371 while (compiling_enum
)
3373 st
= next_statement ();
3381 seen_enumerator
= 1;
3382 accept_statement (st
);
3387 if (!seen_enumerator
)
3388 gfc_error ("ENUM declaration at %C has no ENUMERATORS");
3389 accept_statement (st
);
3393 gfc_free_enum_history ();
3394 unexpected_statement (st
);
3402 /* Parse an interface. We must be able to deal with the possibility
3403 of recursive interfaces. The parse_spec() subroutine is mutually
3404 recursive with parse_interface(). */
3406 static gfc_statement
parse_spec (gfc_statement
);
3409 parse_interface (void)
3411 gfc_compile_state new_state
= COMP_NONE
, current_state
;
3412 gfc_symbol
*prog_unit
, *sym
;
3413 gfc_interface_info save
;
3414 gfc_state_data s1
, s2
;
3417 accept_statement (ST_INTERFACE
);
3419 current_interface
.ns
= gfc_current_ns
;
3420 save
= current_interface
;
3422 sym
= (current_interface
.type
== INTERFACE_GENERIC
3423 || current_interface
.type
== INTERFACE_USER_OP
)
3424 ? gfc_new_block
: NULL
;
3426 push_state (&s1
, COMP_INTERFACE
, sym
);
3427 current_state
= COMP_NONE
;
3430 gfc_current_ns
= gfc_get_namespace (current_interface
.ns
, 0);
3432 st
= next_statement ();
3440 if (st
== ST_SUBROUTINE
)
3441 new_state
= COMP_SUBROUTINE
;
3442 else if (st
== ST_FUNCTION
)
3443 new_state
= COMP_FUNCTION
;
3444 if (gfc_new_block
->attr
.pointer
)
3446 gfc_new_block
->attr
.pointer
= 0;
3447 gfc_new_block
->attr
.proc_pointer
= 1;
3449 if (!gfc_add_explicit_interface (gfc_new_block
, IFSRC_IFBODY
,
3450 gfc_new_block
->formal
, NULL
))
3452 reject_statement ();
3453 gfc_free_namespace (gfc_current_ns
);
3456 /* F2008 C1210 forbids the IMPORT statement in module procedure
3457 interface bodies and the flag is set to import symbols. */
3458 if (gfc_new_block
->attr
.module_procedure
)
3459 gfc_current_ns
->has_import_set
= 1;
3463 case ST_MODULE_PROC
: /* The module procedure matcher makes
3464 sure the context is correct. */
3465 accept_statement (st
);
3466 gfc_free_namespace (gfc_current_ns
);
3469 case ST_END_INTERFACE
:
3470 gfc_free_namespace (gfc_current_ns
);
3471 gfc_current_ns
= current_interface
.ns
;
3475 gfc_error ("Unexpected %s statement in INTERFACE block at %C",
3476 gfc_ascii_statement (st
));
3477 reject_statement ();
3478 gfc_free_namespace (gfc_current_ns
);
3483 /* Make sure that the generic name has the right attribute. */
3484 if (current_interface
.type
== INTERFACE_GENERIC
3485 && current_state
== COMP_NONE
)
3487 if (new_state
== COMP_FUNCTION
&& sym
)
3488 gfc_add_function (&sym
->attr
, sym
->name
, NULL
);
3489 else if (new_state
== COMP_SUBROUTINE
&& sym
)
3490 gfc_add_subroutine (&sym
->attr
, sym
->name
, NULL
);
3492 current_state
= new_state
;
3495 if (current_interface
.type
== INTERFACE_ABSTRACT
)
3497 gfc_add_abstract (&gfc_new_block
->attr
, &gfc_current_locus
);
3498 if (gfc_is_intrinsic_typename (gfc_new_block
->name
))
3499 gfc_error ("Name %qs of ABSTRACT INTERFACE at %C "
3500 "cannot be the same as an intrinsic type",
3501 gfc_new_block
->name
);
3504 push_state (&s2
, new_state
, gfc_new_block
);
3505 accept_statement (st
);
3506 prog_unit
= gfc_new_block
;
3507 prog_unit
->formal_ns
= gfc_current_ns
;
3508 if (prog_unit
== prog_unit
->formal_ns
->proc_name
3509 && prog_unit
->ns
!= prog_unit
->formal_ns
)
3513 /* Read data declaration statements. */
3514 st
= parse_spec (ST_NONE
);
3515 in_specification_block
= true;
3517 /* Since the interface block does not permit an IMPLICIT statement,
3518 the default type for the function or the result must be taken
3519 from the formal namespace. */
3520 if (new_state
== COMP_FUNCTION
)
3522 if (prog_unit
->result
== prog_unit
3523 && prog_unit
->ts
.type
== BT_UNKNOWN
)
3524 gfc_set_default_type (prog_unit
, 1, prog_unit
->formal_ns
);
3525 else if (prog_unit
->result
!= prog_unit
3526 && prog_unit
->result
->ts
.type
== BT_UNKNOWN
)
3527 gfc_set_default_type (prog_unit
->result
, 1,
3528 prog_unit
->formal_ns
);
3531 if (st
!= ST_END_SUBROUTINE
&& st
!= ST_END_FUNCTION
)
3533 gfc_error ("Unexpected %s statement at %C in INTERFACE body",
3534 gfc_ascii_statement (st
));
3535 reject_statement ();
3539 /* Add EXTERNAL attribute to function or subroutine. */
3540 if (current_interface
.type
!= INTERFACE_ABSTRACT
&& !prog_unit
->attr
.dummy
)
3541 gfc_add_external (&prog_unit
->attr
, &gfc_current_locus
);
3543 current_interface
= save
;
3544 gfc_add_interface (prog_unit
);
3547 if (current_interface
.ns
3548 && current_interface
.ns
->proc_name
3549 && strcmp (current_interface
.ns
->proc_name
->name
,
3550 prog_unit
->name
) == 0)
3551 gfc_error ("INTERFACE procedure %qs at %L has the same name as the "
3552 "enclosing procedure", prog_unit
->name
,
3553 ¤t_interface
.ns
->proc_name
->declared_at
);
3562 /* Associate function characteristics by going back to the function
3563 declaration and rematching the prefix. */
3566 match_deferred_characteristics (gfc_typespec
* ts
)
3569 match m
= MATCH_ERROR
;
3570 char name
[GFC_MAX_SYMBOL_LEN
+ 1];
3572 loc
= gfc_current_locus
;
3574 gfc_current_locus
= gfc_current_block ()->declared_at
;
3577 gfc_buffer_error (true);
3578 m
= gfc_match_prefix (ts
);
3579 gfc_buffer_error (false);
3581 if (ts
->type
== BT_DERIVED
)
3589 /* Only permit one go at the characteristic association. */
3593 /* Set the function locus correctly. If we have not found the
3594 function name, there is an error. */
3596 && gfc_match ("function% %n", name
) == MATCH_YES
3597 && strcmp (name
, gfc_current_block ()->name
) == 0)
3599 gfc_current_block ()->declared_at
= gfc_current_locus
;
3600 gfc_commit_symbols ();
3605 gfc_undo_symbols ();
3608 gfc_current_locus
=loc
;
3613 /* Check specification-expressions in the function result of the currently
3614 parsed block and ensure they are typed (give an IMPLICIT type if necessary).
3615 For return types specified in a FUNCTION prefix, the IMPLICIT rules of the
3616 scope are not yet parsed so this has to be delayed up to parse_spec. */
3619 check_function_result_typed (void)
3623 gcc_assert (gfc_current_state () == COMP_FUNCTION
);
3625 if (!gfc_current_ns
->proc_name
->result
) return;
3627 ts
= gfc_current_ns
->proc_name
->result
->ts
;
3629 /* Check type-parameters, at the moment only CHARACTER lengths possible. */
3630 /* TODO: Extend when KIND type parameters are implemented. */
3631 if (ts
.type
== BT_CHARACTER
&& ts
.u
.cl
&& ts
.u
.cl
->length
)
3632 gfc_expr_check_typed (ts
.u
.cl
->length
, gfc_current_ns
, true);
3636 /* Parse a set of specification statements. Returns the statement
3637 that doesn't fit. */
3639 static gfc_statement
3640 parse_spec (gfc_statement st
)
3643 bool function_result_typed
= false;
3644 bool bad_characteristic
= false;
3647 in_specification_block
= true;
3649 verify_st_order (&ss
, ST_NONE
, false);
3651 st
= next_statement ();
3653 /* If we are not inside a function or don't have a result specified so far,
3654 do nothing special about it. */
3655 if (gfc_current_state () != COMP_FUNCTION
)
3656 function_result_typed
= true;
3659 gfc_symbol
* proc
= gfc_current_ns
->proc_name
;
3662 if (proc
->result
->ts
.type
== BT_UNKNOWN
)
3663 function_result_typed
= true;
3668 /* If we're inside a BLOCK construct, some statements are disallowed.
3669 Check this here. Attribute declaration statements like INTENT, OPTIONAL
3670 or VALUE are also disallowed, but they don't have a particular ST_*
3671 key so we have to check for them individually in their matcher routine. */
3672 if (gfc_current_state () == COMP_BLOCK
)
3676 case ST_IMPLICIT_NONE
:
3679 case ST_EQUIVALENCE
:
3680 case ST_STATEMENT_FUNCTION
:
3681 gfc_error ("%s statement is not allowed inside of BLOCK at %C",
3682 gfc_ascii_statement (st
));
3683 reject_statement ();
3689 else if (gfc_current_state () == COMP_BLOCK_DATA
)
3690 /* Fortran 2008, C1116. */
3697 case ST_DERIVED_DECL
:
3698 case ST_END_BLOCK_DATA
:
3699 case ST_EQUIVALENCE
:
3701 case ST_IMPLICIT_NONE
:
3703 case ST_STRUCTURE_DECL
:
3712 gfc_error ("%s statement is not allowed inside of BLOCK DATA at %C",
3713 gfc_ascii_statement (st
));
3714 reject_statement ();
3718 /* If we find a statement that can not be followed by an IMPLICIT statement
3719 (and thus we can expect to see none any further), type the function result
3720 if it has not yet been typed. Be careful not to give the END statement
3721 to verify_st_order! */
3722 if (!function_result_typed
&& st
!= ST_GET_FCN_CHARACTERISTICS
)
3724 bool verify_now
= false;
3726 if (st
== ST_END_FUNCTION
|| st
== ST_CONTAINS
)
3731 verify_st_order (&dummyss
, ST_NONE
, false);
3732 verify_st_order (&dummyss
, st
, false);
3734 if (!verify_st_order (&dummyss
, ST_IMPLICIT
, true))
3740 check_function_result_typed ();
3741 function_result_typed
= true;
3750 case ST_IMPLICIT_NONE
:
3752 if (!function_result_typed
)
3754 check_function_result_typed ();
3755 function_result_typed
= true;
3761 case ST_DATA
: /* Not allowed in interfaces */
3762 if (gfc_current_state () == COMP_INTERFACE
)
3772 case ST_STRUCTURE_DECL
:
3773 case ST_DERIVED_DECL
:
3777 if (!verify_st_order (&ss
, st
, false))
3779 reject_statement ();
3780 st
= next_statement ();
3790 case ST_STRUCTURE_DECL
:
3791 parse_struct_map (ST_STRUCTURE_DECL
);
3794 case ST_DERIVED_DECL
:
3800 if (gfc_current_state () != COMP_MODULE
)
3802 gfc_error ("%s statement must appear in a MODULE",
3803 gfc_ascii_statement (st
));
3804 reject_statement ();
3808 if (gfc_current_ns
->default_access
!= ACCESS_UNKNOWN
)
3810 gfc_error ("%s statement at %C follows another accessibility "
3811 "specification", gfc_ascii_statement (st
));
3812 reject_statement ();
3816 gfc_current_ns
->default_access
= (st
== ST_PUBLIC
)
3817 ? ACCESS_PUBLIC
: ACCESS_PRIVATE
;
3821 case ST_STATEMENT_FUNCTION
:
3822 if (gfc_current_state () == COMP_MODULE
3823 || gfc_current_state () == COMP_SUBMODULE
)
3825 unexpected_statement (st
);
3833 accept_statement (st
);
3834 st
= next_statement ();
3838 accept_statement (st
);
3840 st
= next_statement ();
3843 case ST_GET_FCN_CHARACTERISTICS
:
3844 /* This statement triggers the association of a function's result
3846 ts
= &gfc_current_block ()->result
->ts
;
3847 if (match_deferred_characteristics (ts
) != MATCH_YES
)
3848 bad_characteristic
= true;
3850 st
= next_statement ();
3857 /* If match_deferred_characteristics failed, then there is an error. */
3858 if (bad_characteristic
)
3860 ts
= &gfc_current_block ()->result
->ts
;
3861 if (ts
->type
!= BT_DERIVED
)
3862 gfc_error ("Bad kind expression for function %qs at %L",
3863 gfc_current_block ()->name
,
3864 &gfc_current_block ()->declared_at
);
3866 gfc_error ("The type for function %qs at %L is not accessible",
3867 gfc_current_block ()->name
,
3868 &gfc_current_block ()->declared_at
);
3870 gfc_current_block ()->ts
.kind
= 0;
3871 /* Keep the derived type; if it's bad, it will be discovered later. */
3872 if (!(ts
->type
== BT_DERIVED
&& ts
->u
.derived
))
3873 ts
->type
= BT_UNKNOWN
;
3876 in_specification_block
= false;
3882 /* Parse a WHERE block, (not a simple WHERE statement). */
3885 parse_where_block (void)
3887 int seen_empty_else
;
3892 accept_statement (ST_WHERE_BLOCK
);
3893 top
= gfc_state_stack
->tail
;
3895 push_state (&s
, COMP_WHERE
, gfc_new_block
);
3897 d
= add_statement ();
3898 d
->expr1
= top
->expr1
;
3904 seen_empty_else
= 0;
3908 st
= next_statement ();
3914 case ST_WHERE_BLOCK
:
3915 parse_where_block ();
3920 accept_statement (st
);
3924 if (seen_empty_else
)
3926 gfc_error ("ELSEWHERE statement at %C follows previous "
3927 "unmasked ELSEWHERE");
3928 reject_statement ();
3932 if (new_st
.expr1
== NULL
)
3933 seen_empty_else
= 1;
3935 d
= new_level (gfc_state_stack
->head
);
3937 d
->expr1
= new_st
.expr1
;
3939 accept_statement (st
);
3944 accept_statement (st
);
3948 gfc_error ("Unexpected %s statement in WHERE block at %C",
3949 gfc_ascii_statement (st
));
3950 reject_statement ();
3954 while (st
!= ST_END_WHERE
);
3960 /* Parse a FORALL block (not a simple FORALL statement). */
3963 parse_forall_block (void)
3969 accept_statement (ST_FORALL_BLOCK
);
3970 top
= gfc_state_stack
->tail
;
3972 push_state (&s
, COMP_FORALL
, gfc_new_block
);
3974 d
= add_statement ();
3975 d
->op
= EXEC_FORALL
;
3980 st
= next_statement ();
3985 case ST_POINTER_ASSIGNMENT
:
3988 accept_statement (st
);
3991 case ST_WHERE_BLOCK
:
3992 parse_where_block ();
3995 case ST_FORALL_BLOCK
:
3996 parse_forall_block ();
4000 accept_statement (st
);
4007 gfc_error ("Unexpected %s statement in FORALL block at %C",
4008 gfc_ascii_statement (st
));
4010 reject_statement ();
4014 while (st
!= ST_END_FORALL
);
4020 static gfc_statement
parse_executable (gfc_statement
);
4022 /* parse the statements of an IF-THEN-ELSEIF-ELSE-ENDIF block. */
4025 parse_if_block (void)
4034 accept_statement (ST_IF_BLOCK
);
4036 top
= gfc_state_stack
->tail
;
4037 push_state (&s
, COMP_IF
, gfc_new_block
);
4039 new_st
.op
= EXEC_IF
;
4040 d
= add_statement ();
4042 d
->expr1
= top
->expr1
;
4048 st
= parse_executable (ST_NONE
);
4058 gfc_error ("ELSE IF statement at %C cannot follow ELSE "
4059 "statement at %L", &else_locus
);
4061 reject_statement ();
4065 d
= new_level (gfc_state_stack
->head
);
4067 d
->expr1
= new_st
.expr1
;
4069 accept_statement (st
);
4076 gfc_error ("Duplicate ELSE statements at %L and %C",
4078 reject_statement ();
4083 else_locus
= gfc_current_locus
;
4085 d
= new_level (gfc_state_stack
->head
);
4088 accept_statement (st
);
4096 unexpected_statement (st
);
4100 while (st
!= ST_ENDIF
);
4103 accept_statement (st
);
4107 /* Parse a SELECT block. */
4110 parse_select_block (void)
4116 accept_statement (ST_SELECT_CASE
);
4118 cp
= gfc_state_stack
->tail
;
4119 push_state (&s
, COMP_SELECT
, gfc_new_block
);
4121 /* Make sure that the next statement is a CASE or END SELECT. */
4124 st
= next_statement ();
4127 if (st
== ST_END_SELECT
)
4129 /* Empty SELECT CASE is OK. */
4130 accept_statement (st
);
4137 gfc_error ("Expected a CASE or END SELECT statement following SELECT "
4140 reject_statement ();
4143 /* At this point, we're got a nonempty select block. */
4144 cp
= new_level (cp
);
4147 accept_statement (st
);
4151 st
= parse_executable (ST_NONE
);
4158 cp
= new_level (gfc_state_stack
->head
);
4160 gfc_clear_new_st ();
4162 accept_statement (st
);
4168 /* Can't have an executable statement because of
4169 parse_executable(). */
4171 unexpected_statement (st
);
4175 while (st
!= ST_END_SELECT
);
4178 accept_statement (st
);
4182 /* Pop the current selector from the SELECT TYPE stack. */
4185 select_type_pop (void)
4187 gfc_select_type_stack
*old
= select_type_stack
;
4188 select_type_stack
= old
->prev
;
4193 /* Parse a SELECT TYPE construct (F03:R821). */
4196 parse_select_type_block (void)
4202 gfc_current_ns
= new_st
.ext
.block
.ns
;
4203 accept_statement (ST_SELECT_TYPE
);
4205 cp
= gfc_state_stack
->tail
;
4206 push_state (&s
, COMP_SELECT_TYPE
, gfc_new_block
);
4208 /* Make sure that the next statement is a TYPE IS, CLASS IS, CLASS DEFAULT
4212 st
= next_statement ();
4215 if (st
== ST_END_SELECT
)
4216 /* Empty SELECT CASE is OK. */
4218 if (st
== ST_TYPE_IS
|| st
== ST_CLASS_IS
)
4221 gfc_error ("Expected TYPE IS, CLASS IS or END SELECT statement "
4222 "following SELECT TYPE at %C");
4224 reject_statement ();
4227 /* At this point, we're got a nonempty select block. */
4228 cp
= new_level (cp
);
4231 accept_statement (st
);
4235 st
= parse_executable (ST_NONE
);
4243 cp
= new_level (gfc_state_stack
->head
);
4245 gfc_clear_new_st ();
4247 accept_statement (st
);
4253 /* Can't have an executable statement because of
4254 parse_executable(). */
4256 unexpected_statement (st
);
4260 while (st
!= ST_END_SELECT
);
4264 accept_statement (st
);
4265 gfc_current_ns
= gfc_current_ns
->parent
;
4270 /* Given a symbol, make sure it is not an iteration variable for a DO
4271 statement. This subroutine is called when the symbol is seen in a
4272 context that causes it to become redefined. If the symbol is an
4273 iterator, we generate an error message and return nonzero. */
4276 gfc_check_do_variable (gfc_symtree
*st
)
4280 for (s
=gfc_state_stack
; s
; s
= s
->previous
)
4281 if (s
->do_variable
== st
)
4283 gfc_error_now ("Variable %qs at %C cannot be redefined inside "
4284 "loop beginning at %L", st
->name
, &s
->head
->loc
);
4292 /* Checks to see if the current statement label closes an enddo.
4293 Returns 0 if not, 1 if closes an ENDDO correctly, or 2 (and issues
4294 an error) if it incorrectly closes an ENDDO. */
4297 check_do_closure (void)
4301 if (gfc_statement_label
== NULL
)
4304 for (p
= gfc_state_stack
; p
; p
= p
->previous
)
4305 if (p
->state
== COMP_DO
|| p
->state
== COMP_DO_CONCURRENT
)
4309 return 0; /* No loops to close */
4311 if (p
->ext
.end_do_label
== gfc_statement_label
)
4313 if (p
== gfc_state_stack
)
4316 gfc_error ("End of nonblock DO statement at %C is within another block");
4320 /* At this point, the label doesn't terminate the innermost loop.
4321 Make sure it doesn't terminate another one. */
4322 for (; p
; p
= p
->previous
)
4323 if ((p
->state
== COMP_DO
|| p
->state
== COMP_DO_CONCURRENT
)
4324 && p
->ext
.end_do_label
== gfc_statement_label
)
4326 gfc_error ("End of nonblock DO statement at %C is interwoven "
4327 "with another DO loop");
4335 /* Parse a series of contained program units. */
4337 static void parse_progunit (gfc_statement
);
4340 /* Parse a CRITICAL block. */
4343 parse_critical_block (void)
4346 gfc_state_data s
, *sd
;
4349 for (sd
= gfc_state_stack
; sd
; sd
= sd
->previous
)
4350 if (sd
->state
== COMP_OMP_STRUCTURED_BLOCK
)
4351 gfc_error_now (is_oacc (sd
)
4352 ? G_("CRITICAL block inside of OpenACC region at %C")
4353 : G_("CRITICAL block inside of OpenMP region at %C"));
4355 s
.ext
.end_do_label
= new_st
.label1
;
4357 accept_statement (ST_CRITICAL
);
4358 top
= gfc_state_stack
->tail
;
4360 push_state (&s
, COMP_CRITICAL
, gfc_new_block
);
4362 d
= add_statement ();
4363 d
->op
= EXEC_CRITICAL
;
4368 st
= parse_executable (ST_NONE
);
4376 case ST_END_CRITICAL
:
4377 if (s
.ext
.end_do_label
!= NULL
4378 && s
.ext
.end_do_label
!= gfc_statement_label
)
4379 gfc_error_now ("Statement label in END CRITICAL at %C does not "
4380 "match CRITICAL label");
4382 if (gfc_statement_label
!= NULL
)
4384 new_st
.op
= EXEC_NOP
;
4390 unexpected_statement (st
);
4394 while (st
!= ST_END_CRITICAL
);
4397 accept_statement (st
);
4401 /* Set up the local namespace for a BLOCK construct. */
4404 gfc_build_block_ns (gfc_namespace
*parent_ns
)
4406 gfc_namespace
* my_ns
;
4407 static int numblock
= 1;
4409 my_ns
= gfc_get_namespace (parent_ns
, 1);
4410 my_ns
->construct_entities
= 1;
4412 /* Give the BLOCK a symbol of flavor LABEL; this is later needed for correct
4413 code generation (so it must not be NULL).
4414 We set its recursive argument if our container procedure is recursive, so
4415 that local variables are accordingly placed on the stack when it
4416 will be necessary. */
4418 my_ns
->proc_name
= gfc_new_block
;
4422 char buffer
[20]; /* Enough to hold "block@2147483648\n". */
4424 snprintf(buffer
, sizeof(buffer
), "block@%d", numblock
++);
4425 gfc_get_symbol (buffer
, my_ns
, &my_ns
->proc_name
);
4426 t
= gfc_add_flavor (&my_ns
->proc_name
->attr
, FL_LABEL
,
4427 my_ns
->proc_name
->name
, NULL
);
4429 gfc_commit_symbol (my_ns
->proc_name
);
4432 if (parent_ns
->proc_name
)
4433 my_ns
->proc_name
->attr
.recursive
= parent_ns
->proc_name
->attr
.recursive
;
4439 /* Parse a BLOCK construct. */
4442 parse_block_construct (void)
4444 gfc_namespace
* my_ns
;
4445 gfc_namespace
* my_parent
;
4448 gfc_notify_std (GFC_STD_F2008
, "BLOCK construct at %C");
4450 my_ns
= gfc_build_block_ns (gfc_current_ns
);
4452 new_st
.op
= EXEC_BLOCK
;
4453 new_st
.ext
.block
.ns
= my_ns
;
4454 new_st
.ext
.block
.assoc
= NULL
;
4455 accept_statement (ST_BLOCK
);
4457 push_state (&s
, COMP_BLOCK
, my_ns
->proc_name
);
4458 gfc_current_ns
= my_ns
;
4459 my_parent
= my_ns
->parent
;
4461 parse_progunit (ST_NONE
);
4463 /* Don't depend on the value of gfc_current_ns; it might have been
4464 reset if the block had errors and was cleaned up. */
4465 gfc_current_ns
= my_parent
;
4471 /* Parse an ASSOCIATE construct. This is essentially a BLOCK construct
4472 behind the scenes with compiler-generated variables. */
4475 parse_associate (void)
4477 gfc_namespace
* my_ns
;
4480 gfc_association_list
* a
;
4482 gfc_notify_std (GFC_STD_F2003
, "ASSOCIATE construct at %C");
4484 my_ns
= gfc_build_block_ns (gfc_current_ns
);
4486 new_st
.op
= EXEC_BLOCK
;
4487 new_st
.ext
.block
.ns
= my_ns
;
4488 gcc_assert (new_st
.ext
.block
.assoc
);
4490 /* Add all associate-names as BLOCK variables. Creating them is enough
4491 for now, they'll get their values during trans-* phase. */
4492 gfc_current_ns
= my_ns
;
4493 for (a
= new_st
.ext
.block
.assoc
; a
; a
= a
->next
)
4497 gfc_array_ref
*array_ref
;
4499 if (gfc_get_sym_tree (a
->name
, NULL
, &a
->st
, false))
4503 sym
->attr
.flavor
= FL_VARIABLE
;
4505 sym
->declared_at
= a
->where
;
4506 gfc_set_sym_referenced (sym
);
4508 /* Initialize the typespec. It is not available in all cases,
4509 however, as it may only be set on the target during resolution.
4510 Still, sometimes it helps to have it right now -- especially
4511 for parsing component references on the associate-name
4512 in case of association to a derived-type. */
4513 sym
->ts
= a
->target
->ts
;
4515 /* Check if the target expression is array valued. This can not always
4516 be done by looking at target.rank, because that might not have been
4517 set yet. Therefore traverse the chain of refs, looking for the last
4518 array ref and evaluate that. */
4520 for (ref
= a
->target
->ref
; ref
; ref
= ref
->next
)
4521 if (ref
->type
== REF_ARRAY
)
4522 array_ref
= &ref
->u
.ar
;
4523 if (array_ref
|| a
->target
->rank
)
4530 /* Count the dimension, that have a non-scalar extend. */
4531 for (dim
= 0; dim
< array_ref
->dimen
; ++dim
)
4532 if (array_ref
->dimen_type
[dim
] != DIMEN_ELEMENT
4533 && !(array_ref
->dimen_type
[dim
] == DIMEN_UNKNOWN
4534 && array_ref
->end
[dim
] == NULL
4535 && array_ref
->start
[dim
] != NULL
))
4539 rank
= a
->target
->rank
;
4540 /* When the rank is greater than zero then sym will be an array. */
4541 if (sym
->ts
.type
== BT_CLASS
)
4543 if ((!CLASS_DATA (sym
)->as
&& rank
!= 0)
4544 || (CLASS_DATA (sym
)->as
4545 && CLASS_DATA (sym
)->as
->rank
!= rank
))
4547 /* Don't just (re-)set the attr and as in the sym.ts,
4548 because this modifies the target's attr and as. Copy the
4549 data and do a build_class_symbol. */
4550 symbol_attribute attr
= CLASS_DATA (a
->target
)->attr
;
4551 int corank
= gfc_get_corank (a
->target
);
4556 as
= gfc_get_array_spec ();
4557 as
->type
= AS_DEFERRED
;
4559 as
->corank
= corank
;
4560 attr
.dimension
= rank
? 1 : 0;
4561 attr
.codimension
= corank
? 1 : 0;
4566 attr
.dimension
= attr
.codimension
= 0;
4569 type
= CLASS_DATA (sym
)->ts
;
4570 if (!gfc_build_class_symbol (&type
,
4574 sym
->ts
.type
= BT_CLASS
;
4575 sym
->attr
.class_ok
= 1;
4578 sym
->attr
.class_ok
= 1;
4580 else if ((!sym
->as
&& rank
!= 0)
4581 || (sym
->as
&& sym
->as
->rank
!= rank
))
4583 as
= gfc_get_array_spec ();
4584 as
->type
= AS_DEFERRED
;
4586 as
->corank
= gfc_get_corank (a
->target
);
4588 sym
->attr
.dimension
= 1;
4590 sym
->attr
.codimension
= 1;
4595 accept_statement (ST_ASSOCIATE
);
4596 push_state (&s
, COMP_ASSOCIATE
, my_ns
->proc_name
);
4599 st
= parse_executable (ST_NONE
);
4606 accept_statement (st
);
4607 my_ns
->code
= gfc_state_stack
->head
;
4611 unexpected_statement (st
);
4615 gfc_current_ns
= gfc_current_ns
->parent
;
4620 /* Parse a DO loop. Note that the ST_CYCLE and ST_EXIT statements are
4621 handled inside of parse_executable(), because they aren't really
4625 parse_do_block (void)
4634 s
.ext
.end_do_label
= new_st
.label1
;
4636 if (new_st
.ext
.iterator
!= NULL
)
4637 stree
= new_st
.ext
.iterator
->var
->symtree
;
4641 accept_statement (ST_DO
);
4643 top
= gfc_state_stack
->tail
;
4644 push_state (&s
, do_op
== EXEC_DO_CONCURRENT
? COMP_DO_CONCURRENT
: COMP_DO
,
4647 s
.do_variable
= stree
;
4649 top
->block
= new_level (top
);
4650 top
->block
->op
= EXEC_DO
;
4653 st
= parse_executable (ST_NONE
);
4661 if (s
.ext
.end_do_label
!= NULL
4662 && s
.ext
.end_do_label
!= gfc_statement_label
)
4663 gfc_error_now ("Statement label in ENDDO at %C doesn't match "
4666 if (gfc_statement_label
!= NULL
)
4668 new_st
.op
= EXEC_NOP
;
4673 case ST_IMPLIED_ENDDO
:
4674 /* If the do-stmt of this DO construct has a do-construct-name,
4675 the corresponding end-do must be an end-do-stmt (with a matching
4676 name, but in that case we must have seen ST_ENDDO first).
4677 We only complain about this in pedantic mode. */
4678 if (gfc_current_block () != NULL
)
4679 gfc_error_now ("Named block DO at %L requires matching ENDDO name",
4680 &gfc_current_block()->declared_at
);
4685 unexpected_statement (st
);
4690 accept_statement (st
);
4694 /* Parse the statements of OpenMP do/parallel do. */
4696 static gfc_statement
4697 parse_omp_do (gfc_statement omp_st
)
4703 accept_statement (omp_st
);
4705 cp
= gfc_state_stack
->tail
;
4706 push_state (&s
, COMP_OMP_STRUCTURED_BLOCK
, NULL
);
4707 np
= new_level (cp
);
4713 st
= next_statement ();
4716 else if (st
== ST_DO
)
4719 unexpected_statement (st
);
4723 if (gfc_statement_label
!= NULL
4724 && gfc_state_stack
->previous
!= NULL
4725 && gfc_state_stack
->previous
->state
== COMP_DO
4726 && gfc_state_stack
->previous
->ext
.end_do_label
== gfc_statement_label
)
4734 there should be no !$OMP END DO. */
4736 return ST_IMPLIED_ENDDO
;
4739 check_do_closure ();
4742 st
= next_statement ();
4743 gfc_statement omp_end_st
= ST_OMP_END_DO
;
4746 case ST_OMP_DISTRIBUTE
: omp_end_st
= ST_OMP_END_DISTRIBUTE
; break;
4747 case ST_OMP_DISTRIBUTE_PARALLEL_DO
:
4748 omp_end_st
= ST_OMP_END_DISTRIBUTE_PARALLEL_DO
;
4750 case ST_OMP_DISTRIBUTE_PARALLEL_DO_SIMD
:
4751 omp_end_st
= ST_OMP_END_DISTRIBUTE_PARALLEL_DO_SIMD
;
4753 case ST_OMP_DISTRIBUTE_SIMD
:
4754 omp_end_st
= ST_OMP_END_DISTRIBUTE_SIMD
;
4756 case ST_OMP_DO
: omp_end_st
= ST_OMP_END_DO
; break;
4757 case ST_OMP_DO_SIMD
: omp_end_st
= ST_OMP_END_DO_SIMD
; break;
4758 case ST_OMP_PARALLEL_DO
: omp_end_st
= ST_OMP_END_PARALLEL_DO
; break;
4759 case ST_OMP_PARALLEL_DO_SIMD
:
4760 omp_end_st
= ST_OMP_END_PARALLEL_DO_SIMD
;
4762 case ST_OMP_SIMD
: omp_end_st
= ST_OMP_END_SIMD
; break;
4763 case ST_OMP_TARGET_PARALLEL_DO
:
4764 omp_end_st
= ST_OMP_END_TARGET_PARALLEL_DO
;
4766 case ST_OMP_TARGET_PARALLEL_DO_SIMD
:
4767 omp_end_st
= ST_OMP_END_TARGET_PARALLEL_DO_SIMD
;
4769 case ST_OMP_TARGET_SIMD
: omp_end_st
= ST_OMP_END_TARGET_SIMD
; break;
4770 case ST_OMP_TARGET_TEAMS_DISTRIBUTE
:
4771 omp_end_st
= ST_OMP_END_TARGET_TEAMS_DISTRIBUTE
;
4773 case ST_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO
:
4774 omp_end_st
= ST_OMP_END_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO
;
4776 case ST_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD
:
4777 omp_end_st
= ST_OMP_END_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD
;
4779 case ST_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD
:
4780 omp_end_st
= ST_OMP_END_TARGET_TEAMS_DISTRIBUTE_SIMD
;
4782 case ST_OMP_TASKLOOP
: omp_end_st
= ST_OMP_END_TASKLOOP
; break;
4783 case ST_OMP_TASKLOOP_SIMD
: omp_end_st
= ST_OMP_END_TASKLOOP_SIMD
; break;
4784 case ST_OMP_TEAMS_DISTRIBUTE
:
4785 omp_end_st
= ST_OMP_END_TEAMS_DISTRIBUTE
;
4787 case ST_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO
:
4788 omp_end_st
= ST_OMP_END_TEAMS_DISTRIBUTE_PARALLEL_DO
;
4790 case ST_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD
:
4791 omp_end_st
= ST_OMP_END_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD
;
4793 case ST_OMP_TEAMS_DISTRIBUTE_SIMD
:
4794 omp_end_st
= ST_OMP_END_TEAMS_DISTRIBUTE_SIMD
;
4796 default: gcc_unreachable ();
4798 if (st
== omp_end_st
)
4800 if (new_st
.op
== EXEC_OMP_END_NOWAIT
)
4801 cp
->ext
.omp_clauses
->nowait
|= new_st
.ext
.omp_bool
;
4803 gcc_assert (new_st
.op
== EXEC_NOP
);
4804 gfc_clear_new_st ();
4805 gfc_commit_symbols ();
4806 gfc_warning_check ();
4807 st
= next_statement ();
4813 /* Parse the statements of OpenMP atomic directive. */
4815 static gfc_statement
4816 parse_omp_oacc_atomic (bool omp_p
)
4818 gfc_statement st
, st_atomic
, st_end_atomic
;
4825 st_atomic
= ST_OMP_ATOMIC
;
4826 st_end_atomic
= ST_OMP_END_ATOMIC
;
4830 st_atomic
= ST_OACC_ATOMIC
;
4831 st_end_atomic
= ST_OACC_END_ATOMIC
;
4833 accept_statement (st_atomic
);
4835 cp
= gfc_state_stack
->tail
;
4836 push_state (&s
, COMP_OMP_STRUCTURED_BLOCK
, NULL
);
4837 np
= new_level (cp
);
4840 np
->ext
.omp_atomic
= cp
->ext
.omp_atomic
;
4841 count
= 1 + ((cp
->ext
.omp_atomic
& GFC_OMP_ATOMIC_MASK
)
4842 == GFC_OMP_ATOMIC_CAPTURE
);
4846 st
= next_statement ();
4849 else if (st
== ST_ASSIGNMENT
)
4851 accept_statement (st
);
4855 unexpected_statement (st
);
4860 st
= next_statement ();
4861 if (st
== st_end_atomic
)
4863 gfc_clear_new_st ();
4864 gfc_commit_symbols ();
4865 gfc_warning_check ();
4866 st
= next_statement ();
4868 else if ((cp
->ext
.omp_atomic
& GFC_OMP_ATOMIC_MASK
)
4869 == GFC_OMP_ATOMIC_CAPTURE
)
4870 gfc_error ("Missing !$OMP END ATOMIC after !$OMP ATOMIC CAPTURE at %C");
4875 /* Parse the statements of an OpenACC structured block. */
4878 parse_oacc_structured_block (gfc_statement acc_st
)
4880 gfc_statement st
, acc_end_st
;
4882 gfc_state_data s
, *sd
;
4884 for (sd
= gfc_state_stack
; sd
; sd
= sd
->previous
)
4885 if (sd
->state
== COMP_CRITICAL
)
4886 gfc_error_now ("OpenACC directive inside of CRITICAL block at %C");
4888 accept_statement (acc_st
);
4890 cp
= gfc_state_stack
->tail
;
4891 push_state (&s
, COMP_OMP_STRUCTURED_BLOCK
, NULL
);
4892 np
= new_level (cp
);
4897 case ST_OACC_PARALLEL
:
4898 acc_end_st
= ST_OACC_END_PARALLEL
;
4900 case ST_OACC_KERNELS
:
4901 acc_end_st
= ST_OACC_END_KERNELS
;
4904 acc_end_st
= ST_OACC_END_DATA
;
4906 case ST_OACC_HOST_DATA
:
4907 acc_end_st
= ST_OACC_END_HOST_DATA
;
4915 st
= parse_executable (ST_NONE
);
4918 else if (st
!= acc_end_st
)
4920 gfc_error ("Expecting %s at %C", gfc_ascii_statement (acc_end_st
));
4921 reject_statement ();
4924 while (st
!= acc_end_st
);
4926 gcc_assert (new_st
.op
== EXEC_NOP
);
4928 gfc_clear_new_st ();
4929 gfc_commit_symbols ();
4930 gfc_warning_check ();
4934 /* Parse the statements of OpenACC loop/parallel loop/kernels loop. */
4936 static gfc_statement
4937 parse_oacc_loop (gfc_statement acc_st
)
4941 gfc_state_data s
, *sd
;
4943 for (sd
= gfc_state_stack
; sd
; sd
= sd
->previous
)
4944 if (sd
->state
== COMP_CRITICAL
)
4945 gfc_error_now ("OpenACC directive inside of CRITICAL block at %C");
4947 accept_statement (acc_st
);
4949 cp
= gfc_state_stack
->tail
;
4950 push_state (&s
, COMP_OMP_STRUCTURED_BLOCK
, NULL
);
4951 np
= new_level (cp
);
4957 st
= next_statement ();
4960 else if (st
== ST_DO
)
4964 gfc_error ("Expected DO loop at %C");
4965 reject_statement ();
4970 if (gfc_statement_label
!= NULL
4971 && gfc_state_stack
->previous
!= NULL
4972 && gfc_state_stack
->previous
->state
== COMP_DO
4973 && gfc_state_stack
->previous
->ext
.end_do_label
== gfc_statement_label
)
4976 return ST_IMPLIED_ENDDO
;
4979 check_do_closure ();
4982 st
= next_statement ();
4983 if (st
== ST_OACC_END_LOOP
)
4984 gfc_warning (0, "Redundant !$ACC END LOOP at %C");
4985 if ((acc_st
== ST_OACC_PARALLEL_LOOP
&& st
== ST_OACC_END_PARALLEL_LOOP
) ||
4986 (acc_st
== ST_OACC_KERNELS_LOOP
&& st
== ST_OACC_END_KERNELS_LOOP
) ||
4987 (acc_st
== ST_OACC_LOOP
&& st
== ST_OACC_END_LOOP
))
4989 gcc_assert (new_st
.op
== EXEC_NOP
);
4990 gfc_clear_new_st ();
4991 gfc_commit_symbols ();
4992 gfc_warning_check ();
4993 st
= next_statement ();
4999 /* Parse the statements of an OpenMP structured block. */
5002 parse_omp_structured_block (gfc_statement omp_st
, bool workshare_stmts_only
)
5004 gfc_statement st
, omp_end_st
;
5008 accept_statement (omp_st
);
5010 cp
= gfc_state_stack
->tail
;
5011 push_state (&s
, COMP_OMP_STRUCTURED_BLOCK
, NULL
);
5012 np
= new_level (cp
);
5018 case ST_OMP_PARALLEL
:
5019 omp_end_st
= ST_OMP_END_PARALLEL
;
5021 case ST_OMP_PARALLEL_SECTIONS
:
5022 omp_end_st
= ST_OMP_END_PARALLEL_SECTIONS
;
5024 case ST_OMP_SECTIONS
:
5025 omp_end_st
= ST_OMP_END_SECTIONS
;
5027 case ST_OMP_ORDERED
:
5028 omp_end_st
= ST_OMP_END_ORDERED
;
5030 case ST_OMP_CRITICAL
:
5031 omp_end_st
= ST_OMP_END_CRITICAL
;
5034 omp_end_st
= ST_OMP_END_MASTER
;
5037 omp_end_st
= ST_OMP_END_SINGLE
;
5040 omp_end_st
= ST_OMP_END_TARGET
;
5042 case ST_OMP_TARGET_DATA
:
5043 omp_end_st
= ST_OMP_END_TARGET_DATA
;
5045 case ST_OMP_TARGET_TEAMS
:
5046 omp_end_st
= ST_OMP_END_TARGET_TEAMS
;
5048 case ST_OMP_TARGET_TEAMS_DISTRIBUTE
:
5049 omp_end_st
= ST_OMP_END_TARGET_TEAMS_DISTRIBUTE
;
5051 case ST_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO
:
5052 omp_end_st
= ST_OMP_END_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO
;
5054 case ST_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD
:
5055 omp_end_st
= ST_OMP_END_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD
;
5057 case ST_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD
:
5058 omp_end_st
= ST_OMP_END_TARGET_TEAMS_DISTRIBUTE_SIMD
;
5061 omp_end_st
= ST_OMP_END_TASK
;
5063 case ST_OMP_TASKGROUP
:
5064 omp_end_st
= ST_OMP_END_TASKGROUP
;
5067 omp_end_st
= ST_OMP_END_TEAMS
;
5069 case ST_OMP_TEAMS_DISTRIBUTE
:
5070 omp_end_st
= ST_OMP_END_TEAMS_DISTRIBUTE
;
5072 case ST_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO
:
5073 omp_end_st
= ST_OMP_END_TEAMS_DISTRIBUTE_PARALLEL_DO
;
5075 case ST_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD
:
5076 omp_end_st
= ST_OMP_END_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD
;
5078 case ST_OMP_TEAMS_DISTRIBUTE_SIMD
:
5079 omp_end_st
= ST_OMP_END_TEAMS_DISTRIBUTE_SIMD
;
5081 case ST_OMP_DISTRIBUTE
:
5082 omp_end_st
= ST_OMP_END_DISTRIBUTE
;
5084 case ST_OMP_DISTRIBUTE_PARALLEL_DO
:
5085 omp_end_st
= ST_OMP_END_DISTRIBUTE_PARALLEL_DO
;
5087 case ST_OMP_DISTRIBUTE_PARALLEL_DO_SIMD
:
5088 omp_end_st
= ST_OMP_END_DISTRIBUTE_PARALLEL_DO_SIMD
;
5090 case ST_OMP_DISTRIBUTE_SIMD
:
5091 omp_end_st
= ST_OMP_END_DISTRIBUTE_SIMD
;
5093 case ST_OMP_WORKSHARE
:
5094 omp_end_st
= ST_OMP_END_WORKSHARE
;
5096 case ST_OMP_PARALLEL_WORKSHARE
:
5097 omp_end_st
= ST_OMP_END_PARALLEL_WORKSHARE
;
5105 if (workshare_stmts_only
)
5107 /* Inside of !$omp workshare, only
5110 where statements and constructs
5111 forall statements and constructs
5115 are allowed. For !$omp critical these
5116 restrictions apply recursively. */
5119 st
= next_statement ();
5130 accept_statement (st
);
5133 case ST_WHERE_BLOCK
:
5134 parse_where_block ();
5137 case ST_FORALL_BLOCK
:
5138 parse_forall_block ();
5141 case ST_OMP_PARALLEL
:
5142 case ST_OMP_PARALLEL_SECTIONS
:
5143 parse_omp_structured_block (st
, false);
5146 case ST_OMP_PARALLEL_WORKSHARE
:
5147 case ST_OMP_CRITICAL
:
5148 parse_omp_structured_block (st
, true);
5151 case ST_OMP_PARALLEL_DO
:
5152 case ST_OMP_PARALLEL_DO_SIMD
:
5153 st
= parse_omp_do (st
);
5157 st
= parse_omp_oacc_atomic (true);
5168 st
= next_statement ();
5172 st
= parse_executable (ST_NONE
);
5175 else if (st
== ST_OMP_SECTION
5176 && (omp_st
== ST_OMP_SECTIONS
5177 || omp_st
== ST_OMP_PARALLEL_SECTIONS
))
5179 np
= new_level (np
);
5183 else if (st
!= omp_end_st
)
5184 unexpected_statement (st
);
5186 while (st
!= omp_end_st
);
5190 case EXEC_OMP_END_NOWAIT
:
5191 cp
->ext
.omp_clauses
->nowait
|= new_st
.ext
.omp_bool
;
5193 case EXEC_OMP_END_CRITICAL
:
5194 if (((cp
->ext
.omp_clauses
== NULL
) ^ (new_st
.ext
.omp_name
== NULL
))
5195 || (new_st
.ext
.omp_name
!= NULL
5196 && strcmp (cp
->ext
.omp_clauses
->critical_name
,
5197 new_st
.ext
.omp_name
) != 0))
5198 gfc_error ("Name after !$omp critical and !$omp end critical does "
5200 free (CONST_CAST (char *, new_st
.ext
.omp_name
));
5201 new_st
.ext
.omp_name
= NULL
;
5203 case EXEC_OMP_END_SINGLE
:
5204 cp
->ext
.omp_clauses
->lists
[OMP_LIST_COPYPRIVATE
]
5205 = new_st
.ext
.omp_clauses
->lists
[OMP_LIST_COPYPRIVATE
];
5206 new_st
.ext
.omp_clauses
->lists
[OMP_LIST_COPYPRIVATE
] = NULL
;
5207 gfc_free_omp_clauses (new_st
.ext
.omp_clauses
);
5215 gfc_clear_new_st ();
5216 gfc_commit_symbols ();
5217 gfc_warning_check ();
5222 /* Accept a series of executable statements. We return the first
5223 statement that doesn't fit to the caller. Any block statements are
5224 passed on to the correct handler, which usually passes the buck
5227 static gfc_statement
5228 parse_executable (gfc_statement st
)
5233 st
= next_statement ();
5237 close_flag
= check_do_closure ();
5242 case ST_END_PROGRAM
:
5245 case ST_END_FUNCTION
:
5250 case ST_END_SUBROUTINE
:
5255 case ST_SELECT_CASE
:
5256 gfc_error ("%s statement at %C cannot terminate a non-block "
5257 "DO loop", gfc_ascii_statement (st
));
5270 gfc_notify_std (GFC_STD_F95_OBS
, "DATA statement at %C after the "
5271 "first executable statement");
5277 accept_statement (st
);
5278 if (close_flag
== 1)
5279 return ST_IMPLIED_ENDDO
;
5283 parse_block_construct ();
5294 case ST_SELECT_CASE
:
5295 parse_select_block ();
5298 case ST_SELECT_TYPE
:
5299 parse_select_type_block ();
5304 if (check_do_closure () == 1)
5305 return ST_IMPLIED_ENDDO
;
5309 parse_critical_block ();
5312 case ST_WHERE_BLOCK
:
5313 parse_where_block ();
5316 case ST_FORALL_BLOCK
:
5317 parse_forall_block ();
5320 case ST_OACC_PARALLEL_LOOP
:
5321 case ST_OACC_KERNELS_LOOP
:
5323 st
= parse_oacc_loop (st
);
5324 if (st
== ST_IMPLIED_ENDDO
)
5328 case ST_OACC_PARALLEL
:
5329 case ST_OACC_KERNELS
:
5331 case ST_OACC_HOST_DATA
:
5332 parse_oacc_structured_block (st
);
5335 case ST_OMP_PARALLEL
:
5336 case ST_OMP_PARALLEL_SECTIONS
:
5337 case ST_OMP_SECTIONS
:
5338 case ST_OMP_ORDERED
:
5339 case ST_OMP_CRITICAL
:
5343 case ST_OMP_TARGET_DATA
:
5344 case ST_OMP_TARGET_PARALLEL
:
5345 case ST_OMP_TARGET_TEAMS
:
5348 case ST_OMP_TASKGROUP
:
5349 parse_omp_structured_block (st
, false);
5352 case ST_OMP_WORKSHARE
:
5353 case ST_OMP_PARALLEL_WORKSHARE
:
5354 parse_omp_structured_block (st
, true);
5357 case ST_OMP_DISTRIBUTE
:
5358 case ST_OMP_DISTRIBUTE_PARALLEL_DO
:
5359 case ST_OMP_DISTRIBUTE_PARALLEL_DO_SIMD
:
5360 case ST_OMP_DISTRIBUTE_SIMD
:
5362 case ST_OMP_DO_SIMD
:
5363 case ST_OMP_PARALLEL_DO
:
5364 case ST_OMP_PARALLEL_DO_SIMD
:
5366 case ST_OMP_TARGET_PARALLEL_DO
:
5367 case ST_OMP_TARGET_PARALLEL_DO_SIMD
:
5368 case ST_OMP_TARGET_TEAMS_DISTRIBUTE
:
5369 case ST_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO
:
5370 case ST_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD
:
5371 case ST_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD
:
5372 case ST_OMP_TASKLOOP
:
5373 case ST_OMP_TASKLOOP_SIMD
:
5374 case ST_OMP_TEAMS_DISTRIBUTE
:
5375 case ST_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO
:
5376 case ST_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD
:
5377 case ST_OMP_TEAMS_DISTRIBUTE_SIMD
:
5378 st
= parse_omp_do (st
);
5379 if (st
== ST_IMPLIED_ENDDO
)
5383 case ST_OACC_ATOMIC
:
5384 st
= parse_omp_oacc_atomic (false);
5388 st
= parse_omp_oacc_atomic (true);
5395 st
= next_statement ();
5400 /* Fix the symbols for sibling functions. These are incorrectly added to
5401 the child namespace as the parser didn't know about this procedure. */
5404 gfc_fixup_sibling_symbols (gfc_symbol
*sym
, gfc_namespace
*siblings
)
5408 gfc_symbol
*old_sym
;
5410 for (ns
= siblings
; ns
; ns
= ns
->sibling
)
5412 st
= gfc_find_symtree (ns
->sym_root
, sym
->name
);
5414 if (!st
|| (st
->n
.sym
->attr
.dummy
&& ns
== st
->n
.sym
->ns
))
5415 goto fixup_contained
;
5417 if ((st
->n
.sym
->attr
.flavor
== FL_DERIVED
5418 && sym
->attr
.generic
&& sym
->attr
.function
)
5419 ||(sym
->attr
.flavor
== FL_DERIVED
5420 && st
->n
.sym
->attr
.generic
&& st
->n
.sym
->attr
.function
))
5421 goto fixup_contained
;
5423 old_sym
= st
->n
.sym
;
5424 if (old_sym
->ns
== ns
5425 && !old_sym
->attr
.contained
5427 /* By 14.6.1.3, host association should be excluded
5428 for the following. */
5429 && !(old_sym
->attr
.external
5430 || (old_sym
->ts
.type
!= BT_UNKNOWN
5431 && !old_sym
->attr
.implicit_type
)
5432 || old_sym
->attr
.flavor
== FL_PARAMETER
5433 || old_sym
->attr
.use_assoc
5434 || old_sym
->attr
.in_common
5435 || old_sym
->attr
.in_equivalence
5436 || old_sym
->attr
.data
5437 || old_sym
->attr
.dummy
5438 || old_sym
->attr
.result
5439 || old_sym
->attr
.dimension
5440 || old_sym
->attr
.allocatable
5441 || old_sym
->attr
.intrinsic
5442 || old_sym
->attr
.generic
5443 || old_sym
->attr
.flavor
== FL_NAMELIST
5444 || old_sym
->attr
.flavor
== FL_LABEL
5445 || old_sym
->attr
.proc
== PROC_ST_FUNCTION
))
5447 /* Replace it with the symbol from the parent namespace. */
5451 gfc_release_symbol (old_sym
);
5455 /* Do the same for any contained procedures. */
5456 gfc_fixup_sibling_symbols (sym
, ns
->contained
);
5461 parse_contained (int module
)
5463 gfc_namespace
*ns
, *parent_ns
, *tmp
;
5464 gfc_state_data s1
, s2
;
5469 int contains_statements
= 0;
5472 push_state (&s1
, COMP_CONTAINS
, NULL
);
5473 parent_ns
= gfc_current_ns
;
5477 gfc_current_ns
= gfc_get_namespace (parent_ns
, 1);
5479 gfc_current_ns
->sibling
= parent_ns
->contained
;
5480 parent_ns
->contained
= gfc_current_ns
;
5483 /* Process the next available statement. We come here if we got an error
5484 and rejected the last statement. */
5485 old_loc
= gfc_current_locus
;
5486 st
= next_statement ();
5495 contains_statements
= 1;
5496 accept_statement (st
);
5499 (st
== ST_FUNCTION
) ? COMP_FUNCTION
: COMP_SUBROUTINE
,
5502 /* For internal procedures, create/update the symbol in the
5503 parent namespace. */
5507 if (gfc_get_symbol (gfc_new_block
->name
, parent_ns
, &sym
))
5508 gfc_error ("Contained procedure %qs at %C is already "
5509 "ambiguous", gfc_new_block
->name
);
5512 if (gfc_add_procedure (&sym
->attr
, PROC_INTERNAL
,
5514 &gfc_new_block
->declared_at
))
5516 if (st
== ST_FUNCTION
)
5517 gfc_add_function (&sym
->attr
, sym
->name
,
5518 &gfc_new_block
->declared_at
);
5520 gfc_add_subroutine (&sym
->attr
, sym
->name
,
5521 &gfc_new_block
->declared_at
);
5525 gfc_commit_symbols ();
5528 sym
= gfc_new_block
;
5530 /* Mark this as a contained function, so it isn't replaced
5531 by other module functions. */
5532 sym
->attr
.contained
= 1;
5534 /* Set implicit_pure so that it can be reset if any of the
5535 tests for purity fail. This is used for some optimisation
5536 during translation. */
5537 if (!sym
->attr
.pure
)
5538 sym
->attr
.implicit_pure
= 1;
5540 parse_progunit (ST_NONE
);
5542 /* Fix up any sibling functions that refer to this one. */
5543 gfc_fixup_sibling_symbols (sym
, gfc_current_ns
);
5544 /* Or refer to any of its alternate entry points. */
5545 for (el
= gfc_current_ns
->entries
; el
; el
= el
->next
)
5546 gfc_fixup_sibling_symbols (el
->sym
, gfc_current_ns
);
5548 gfc_current_ns
->code
= s2
.head
;
5549 gfc_current_ns
= parent_ns
;
5554 /* These statements are associated with the end of the host unit. */
5555 case ST_END_FUNCTION
:
5557 case ST_END_SUBMODULE
:
5558 case ST_END_PROGRAM
:
5559 case ST_END_SUBROUTINE
:
5560 accept_statement (st
);
5561 gfc_current_ns
->code
= s1
.head
;
5565 gfc_error ("Unexpected %s statement in CONTAINS section at %C",
5566 gfc_ascii_statement (st
));
5567 reject_statement ();
5573 while (st
!= ST_END_FUNCTION
&& st
!= ST_END_SUBROUTINE
5574 && st
!= ST_END_MODULE
&& st
!= ST_END_SUBMODULE
5575 && st
!= ST_END_PROGRAM
);
5577 /* The first namespace in the list is guaranteed to not have
5578 anything (worthwhile) in it. */
5579 tmp
= gfc_current_ns
;
5580 gfc_current_ns
= parent_ns
;
5581 if (seen_error
&& tmp
->refs
> 1)
5582 gfc_free_namespace (tmp
);
5584 ns
= gfc_current_ns
->contained
;
5585 gfc_current_ns
->contained
= ns
->sibling
;
5586 gfc_free_namespace (ns
);
5589 if (!contains_statements
)
5590 gfc_notify_std (GFC_STD_F2008
, "CONTAINS statement without "
5591 "FUNCTION or SUBROUTINE statement at %L", &old_loc
);
5595 /* The result variable in a MODULE PROCEDURE needs to be created and
5596 its characteristics copied from the interface since it is neither
5597 declared in the procedure declaration nor in the specification
5601 get_modproc_result (void)
5604 if (gfc_state_stack
->previous
5605 && gfc_state_stack
->previous
->state
== COMP_CONTAINS
5606 && gfc_state_stack
->previous
->previous
->state
== COMP_SUBMODULE
)
5608 proc
= gfc_current_ns
->proc_name
? gfc_current_ns
->proc_name
: NULL
;
5610 && proc
->attr
.function
5612 && proc
->tlink
->result
5613 && proc
->tlink
->result
!= proc
->tlink
)
5615 gfc_copy_dummy_sym (&proc
->result
, proc
->tlink
->result
, 1);
5616 gfc_set_sym_referenced (proc
->result
);
5617 proc
->result
->attr
.if_source
= IFSRC_DECL
;
5618 gfc_commit_symbol (proc
->result
);
5624 /* Parse a PROGRAM, SUBROUTINE, FUNCTION unit or BLOCK construct. */
5627 parse_progunit (gfc_statement st
)
5633 && gfc_new_block
->abr_modproc_decl
5634 && gfc_new_block
->attr
.function
)
5635 get_modproc_result ();
5637 st
= parse_spec (st
);
5644 /* This is not allowed within BLOCK! */
5645 if (gfc_current_state () != COMP_BLOCK
)
5650 accept_statement (st
);
5657 if (gfc_current_state () == COMP_FUNCTION
)
5658 gfc_check_function_type (gfc_current_ns
);
5663 st
= parse_executable (st
);
5671 /* This is not allowed within BLOCK! */
5672 if (gfc_current_state () != COMP_BLOCK
)
5677 accept_statement (st
);
5684 unexpected_statement (st
);
5685 reject_statement ();
5686 st
= next_statement ();
5692 for (p
= gfc_state_stack
; p
; p
= p
->previous
)
5693 if (p
->state
== COMP_CONTAINS
)
5696 if (gfc_find_state (COMP_MODULE
) == true
5697 || gfc_find_state (COMP_SUBMODULE
) == true)
5702 gfc_error ("CONTAINS statement at %C is already in a contained "
5704 reject_statement ();
5705 st
= next_statement ();
5709 parse_contained (0);
5712 gfc_current_ns
->code
= gfc_state_stack
->head
;
5716 /* Come here to complain about a global symbol already in use as
5720 gfc_global_used (gfc_gsymbol
*sym
, locus
*where
)
5725 where
= &gfc_current_locus
;
5735 case GSYM_SUBROUTINE
:
5736 name
= "SUBROUTINE";
5741 case GSYM_BLOCK_DATA
:
5742 name
= "BLOCK DATA";
5753 if (sym
->binding_label
)
5754 gfc_error ("Global binding name %qs at %L is already being used "
5755 "as a %s at %L", sym
->binding_label
, where
, name
,
5758 gfc_error ("Global name %qs at %L is already being used as "
5759 "a %s at %L", sym
->name
, where
, name
, &sym
->where
);
5763 if (sym
->binding_label
)
5764 gfc_error ("Global binding name %qs at %L is already being used "
5765 "at %L", sym
->binding_label
, where
, &sym
->where
);
5767 gfc_error ("Global name %qs at %L is already being used at %L",
5768 sym
->name
, where
, &sym
->where
);
5773 /* Parse a block data program unit. */
5776 parse_block_data (void)
5779 static locus blank_locus
;
5780 static int blank_block
=0;
5783 gfc_current_ns
->proc_name
= gfc_new_block
;
5784 gfc_current_ns
->is_block_data
= 1;
5786 if (gfc_new_block
== NULL
)
5789 gfc_error ("Blank BLOCK DATA at %C conflicts with "
5790 "prior BLOCK DATA at %L", &blank_locus
);
5794 blank_locus
= gfc_current_locus
;
5799 s
= gfc_get_gsymbol (gfc_new_block
->name
);
5801 || (s
->type
!= GSYM_UNKNOWN
&& s
->type
!= GSYM_BLOCK_DATA
))
5802 gfc_global_used (s
, &gfc_new_block
->declared_at
);
5805 s
->type
= GSYM_BLOCK_DATA
;
5806 s
->where
= gfc_new_block
->declared_at
;
5811 st
= parse_spec (ST_NONE
);
5813 while (st
!= ST_END_BLOCK_DATA
)
5815 gfc_error ("Unexpected %s statement in BLOCK DATA at %C",
5816 gfc_ascii_statement (st
));
5817 reject_statement ();
5818 st
= next_statement ();
5823 /* Following the association of the ancestor (sub)module symbols, they
5824 must be set host rather than use associated and all must be public.
5825 They are flagged up by 'used_in_submodule' so that they can be set
5826 DECL_EXTERNAL in trans_decl.c(gfc_finish_var_decl). Otherwise the
5827 linker chokes on multiple symbol definitions. */
5830 set_syms_host_assoc (gfc_symbol
*sym
)
5833 const char dot
[2] = ".";
5834 char parent1
[GFC_MAX_SYMBOL_LEN
+ 1];
5835 char parent2
[GFC_MAX_SYMBOL_LEN
+ 1];
5840 if (sym
->attr
.module_procedure
)
5841 sym
->attr
.external
= 0;
5843 sym
->attr
.use_assoc
= 0;
5844 sym
->attr
.host_assoc
= 1;
5845 sym
->attr
.used_in_submodule
=1;
5847 if (sym
->attr
.flavor
== FL_DERIVED
)
5849 /* Derived types with PRIVATE components that are declared in
5850 modules other than the parent module must not be changed to be
5851 PUBLIC. The 'use-assoc' attribute must be reset so that the
5852 test in symbol.c(gfc_find_component) works correctly. This is
5853 not necessary for PRIVATE symbols since they are not read from
5855 memset(parent1
, '\0', sizeof(parent1
));
5856 memset(parent2
, '\0', sizeof(parent2
));
5857 strcpy (parent1
, gfc_new_block
->name
);
5858 strcpy (parent2
, sym
->module
);
5859 if (strcmp (strtok (parent1
, dot
), strtok (parent2
, dot
)) == 0)
5861 for (c
= sym
->components
; c
; c
= c
->next
)
5862 c
->attr
.access
= ACCESS_PUBLIC
;
5866 sym
->attr
.use_assoc
= 1;
5867 sym
->attr
.host_assoc
= 0;
5872 /* Parse a module subprogram. */
5881 s
= gfc_get_gsymbol (gfc_new_block
->name
);
5882 if (s
->defined
|| (s
->type
!= GSYM_UNKNOWN
&& s
->type
!= GSYM_MODULE
))
5883 gfc_global_used (s
, &gfc_new_block
->declared_at
);
5886 s
->type
= GSYM_MODULE
;
5887 s
->where
= gfc_new_block
->declared_at
;
5891 /* Something is nulling the module_list after this point. This is good
5892 since it allows us to 'USE' the parent modules that the submodule
5893 inherits and to set (most) of the symbols as host associated. */
5894 if (gfc_current_state () == COMP_SUBMODULE
)
5897 gfc_traverse_ns (gfc_current_ns
, set_syms_host_assoc
);
5900 st
= parse_spec (ST_NONE
);
5910 parse_contained (1);
5914 case ST_END_SUBMODULE
:
5915 accept_statement (st
);
5919 gfc_error ("Unexpected %s statement in MODULE at %C",
5920 gfc_ascii_statement (st
));
5923 reject_statement ();
5924 st
= next_statement ();
5928 /* Make sure not to free the namespace twice on error. */
5930 s
->ns
= gfc_current_ns
;
5934 /* Add a procedure name to the global symbol table. */
5937 add_global_procedure (bool sub
)
5941 /* Only in Fortran 2003: For procedures with a binding label also the Fortran
5942 name is a global identifier. */
5943 if (!gfc_new_block
->binding_label
|| gfc_notification_std (GFC_STD_F2008
))
5945 s
= gfc_get_gsymbol (gfc_new_block
->name
);
5948 || (s
->type
!= GSYM_UNKNOWN
5949 && s
->type
!= (sub
? GSYM_SUBROUTINE
: GSYM_FUNCTION
)))
5951 gfc_global_used (s
, &gfc_new_block
->declared_at
);
5952 /* Silence follow-up errors. */
5953 gfc_new_block
->binding_label
= NULL
;
5957 s
->type
= sub
? GSYM_SUBROUTINE
: GSYM_FUNCTION
;
5958 s
->sym_name
= gfc_new_block
->name
;
5959 s
->where
= gfc_new_block
->declared_at
;
5961 s
->ns
= gfc_current_ns
;
5965 /* Don't add the symbol multiple times. */
5966 if (gfc_new_block
->binding_label
5967 && (!gfc_notification_std (GFC_STD_F2008
)
5968 || strcmp (gfc_new_block
->name
, gfc_new_block
->binding_label
) != 0))
5970 s
= gfc_get_gsymbol (gfc_new_block
->binding_label
);
5973 || (s
->type
!= GSYM_UNKNOWN
5974 && s
->type
!= (sub
? GSYM_SUBROUTINE
: GSYM_FUNCTION
)))
5976 gfc_global_used (s
, &gfc_new_block
->declared_at
);
5977 /* Silence follow-up errors. */
5978 gfc_new_block
->binding_label
= NULL
;
5982 s
->type
= sub
? GSYM_SUBROUTINE
: GSYM_FUNCTION
;
5983 s
->sym_name
= gfc_new_block
->name
;
5984 s
->binding_label
= gfc_new_block
->binding_label
;
5985 s
->where
= gfc_new_block
->declared_at
;
5987 s
->ns
= gfc_current_ns
;
5993 /* Add a program to the global symbol table. */
5996 add_global_program (void)
6000 if (gfc_new_block
== NULL
)
6002 s
= gfc_get_gsymbol (gfc_new_block
->name
);
6004 if (s
->defined
|| (s
->type
!= GSYM_UNKNOWN
&& s
->type
!= GSYM_PROGRAM
))
6005 gfc_global_used (s
, &gfc_new_block
->declared_at
);
6008 s
->type
= GSYM_PROGRAM
;
6009 s
->where
= gfc_new_block
->declared_at
;
6011 s
->ns
= gfc_current_ns
;
6016 /* Resolve all the program units. */
6018 resolve_all_program_units (gfc_namespace
*gfc_global_ns_list
)
6020 gfc_free_dt_list ();
6021 gfc_current_ns
= gfc_global_ns_list
;
6022 for (; gfc_current_ns
; gfc_current_ns
= gfc_current_ns
->sibling
)
6024 if (gfc_current_ns
->proc_name
6025 && gfc_current_ns
->proc_name
->attr
.flavor
== FL_MODULE
)
6026 continue; /* Already resolved. */
6028 if (gfc_current_ns
->proc_name
)
6029 gfc_current_locus
= gfc_current_ns
->proc_name
->declared_at
;
6030 gfc_resolve (gfc_current_ns
);
6031 gfc_current_ns
->derived_types
= gfc_derived_types
;
6032 gfc_derived_types
= NULL
;
6038 clean_up_modules (gfc_gsymbol
*gsym
)
6043 clean_up_modules (gsym
->left
);
6044 clean_up_modules (gsym
->right
);
6046 if (gsym
->type
!= GSYM_MODULE
|| !gsym
->ns
)
6049 gfc_current_ns
= gsym
->ns
;
6050 gfc_derived_types
= gfc_current_ns
->derived_types
;
6057 /* Translate all the program units. This could be in a different order
6058 to resolution if there are forward references in the file. */
6060 translate_all_program_units (gfc_namespace
*gfc_global_ns_list
)
6064 gfc_current_ns
= gfc_global_ns_list
;
6065 gfc_get_errors (NULL
, &errors
);
6067 /* We first translate all modules to make sure that later parts
6068 of the program can use the decl. Then we translate the nonmodules. */
6070 for (; !errors
&& gfc_current_ns
; gfc_current_ns
= gfc_current_ns
->sibling
)
6072 if (!gfc_current_ns
->proc_name
6073 || gfc_current_ns
->proc_name
->attr
.flavor
!= FL_MODULE
)
6076 gfc_current_locus
= gfc_current_ns
->proc_name
->declared_at
;
6077 gfc_derived_types
= gfc_current_ns
->derived_types
;
6078 gfc_generate_module_code (gfc_current_ns
);
6079 gfc_current_ns
->translated
= 1;
6082 gfc_current_ns
= gfc_global_ns_list
;
6083 for (; !errors
&& gfc_current_ns
; gfc_current_ns
= gfc_current_ns
->sibling
)
6085 if (gfc_current_ns
->proc_name
6086 && gfc_current_ns
->proc_name
->attr
.flavor
== FL_MODULE
)
6089 gfc_current_locus
= gfc_current_ns
->proc_name
->declared_at
;
6090 gfc_derived_types
= gfc_current_ns
->derived_types
;
6091 gfc_generate_code (gfc_current_ns
);
6092 gfc_current_ns
->translated
= 1;
6095 /* Clean up all the namespaces after translation. */
6096 gfc_current_ns
= gfc_global_ns_list
;
6097 for (;gfc_current_ns
;)
6101 if (gfc_current_ns
->proc_name
6102 && gfc_current_ns
->proc_name
->attr
.flavor
== FL_MODULE
)
6104 gfc_current_ns
= gfc_current_ns
->sibling
;
6108 ns
= gfc_current_ns
->sibling
;
6109 gfc_derived_types
= gfc_current_ns
->derived_types
;
6111 gfc_current_ns
= ns
;
6114 clean_up_modules (gfc_gsym_root
);
6118 /* Top level parser. */
6121 gfc_parse_file (void)
6123 int seen_program
, errors_before
, errors
;
6124 gfc_state_data top
, s
;
6127 gfc_namespace
*next
;
6129 gfc_start_source_files ();
6131 top
.state
= COMP_NONE
;
6133 top
.previous
= NULL
;
6134 top
.head
= top
.tail
= NULL
;
6135 top
.do_variable
= NULL
;
6137 gfc_state_stack
= &top
;
6139 gfc_clear_new_st ();
6141 gfc_statement_label
= NULL
;
6143 if (setjmp (eof_buf
))
6144 return false; /* Come here on unexpected EOF */
6146 /* Prepare the global namespace that will contain the
6148 gfc_global_ns_list
= next
= NULL
;
6153 /* Exit early for empty files. */
6157 in_specification_block
= true;
6160 st
= next_statement ();
6169 goto duplicate_main
;
6171 prog_locus
= gfc_current_locus
;
6173 push_state (&s
, COMP_PROGRAM
, gfc_new_block
);
6174 main_program_symbol (gfc_current_ns
, gfc_new_block
->name
);
6175 accept_statement (st
);
6176 add_global_program ();
6177 parse_progunit (ST_NONE
);
6181 add_global_procedure (true);
6182 push_state (&s
, COMP_SUBROUTINE
, gfc_new_block
);
6183 accept_statement (st
);
6184 parse_progunit (ST_NONE
);
6188 add_global_procedure (false);
6189 push_state (&s
, COMP_FUNCTION
, gfc_new_block
);
6190 accept_statement (st
);
6191 parse_progunit (ST_NONE
);
6195 push_state (&s
, COMP_BLOCK_DATA
, gfc_new_block
);
6196 accept_statement (st
);
6197 parse_block_data ();
6201 push_state (&s
, COMP_MODULE
, gfc_new_block
);
6202 accept_statement (st
);
6204 gfc_get_errors (NULL
, &errors_before
);
6209 push_state (&s
, COMP_SUBMODULE
, gfc_new_block
);
6210 accept_statement (st
);
6212 gfc_get_errors (NULL
, &errors_before
);
6216 /* Anything else starts a nameless main program block. */
6219 goto duplicate_main
;
6221 prog_locus
= gfc_current_locus
;
6223 push_state (&s
, COMP_PROGRAM
, gfc_new_block
);
6224 main_program_symbol (gfc_current_ns
, "MAIN__");
6225 parse_progunit (st
);
6229 /* Handle the non-program units. */
6230 gfc_current_ns
->code
= s
.head
;
6232 gfc_resolve (gfc_current_ns
);
6234 /* Dump the parse tree if requested. */
6235 if (flag_dump_fortran_original
)
6236 gfc_dump_parse_tree (gfc_current_ns
, stdout
);
6238 if (flag_c_prototypes
)
6239 gfc_dump_c_prototypes (gfc_current_ns
, stdout
);
6241 gfc_get_errors (NULL
, &errors
);
6242 if (s
.state
== COMP_MODULE
|| s
.state
== COMP_SUBMODULE
)
6244 gfc_dump_module (s
.sym
->name
, errors_before
== errors
);
6245 gfc_current_ns
->derived_types
= gfc_derived_types
;
6246 gfc_derived_types
= NULL
;
6252 gfc_generate_code (gfc_current_ns
);
6260 /* The main program and non-contained procedures are put
6261 in the global namespace list, so that they can be processed
6262 later and all their interfaces resolved. */
6263 gfc_current_ns
->code
= s
.head
;
6266 for (; next
->sibling
; next
= next
->sibling
)
6268 next
->sibling
= gfc_current_ns
;
6271 gfc_global_ns_list
= gfc_current_ns
;
6273 next
= gfc_current_ns
;
6279 /* Do the resolution. */
6280 resolve_all_program_units (gfc_global_ns_list
);
6282 /* Do the parse tree dump. */
6283 gfc_current_ns
= flag_dump_fortran_original
? gfc_global_ns_list
: NULL
;
6285 for (; gfc_current_ns
; gfc_current_ns
= gfc_current_ns
->sibling
)
6286 if (!gfc_current_ns
->proc_name
6287 || gfc_current_ns
->proc_name
->attr
.flavor
!= FL_MODULE
)
6289 gfc_dump_parse_tree (gfc_current_ns
, stdout
);
6290 fputs ("------------------------------------------\n\n", stdout
);
6293 /* Do the translation. */
6294 translate_all_program_units (gfc_global_ns_list
);
6296 gfc_end_source_files ();
6300 /* If we see a duplicate main program, shut down. If the second
6301 instance is an implied main program, i.e. data decls or executable
6302 statements, we're in for lots of errors. */
6303 gfc_error ("Two main PROGRAMs at %L and %C", &prog_locus
);
6304 reject_statement ();
6309 /* Return true if this state data represents an OpenACC region. */
6311 is_oacc (gfc_state_data
*sd
)
6313 switch (sd
->construct
->op
)
6315 case EXEC_OACC_PARALLEL_LOOP
:
6316 case EXEC_OACC_PARALLEL
:
6317 case EXEC_OACC_KERNELS_LOOP
:
6318 case EXEC_OACC_KERNELS
:
6319 case EXEC_OACC_DATA
:
6320 case EXEC_OACC_HOST_DATA
:
6321 case EXEC_OACC_LOOP
:
6322 case EXEC_OACC_UPDATE
:
6323 case EXEC_OACC_WAIT
:
6324 case EXEC_OACC_CACHE
:
6325 case EXEC_OACC_ENTER_DATA
:
6326 case EXEC_OACC_EXIT_DATA
:
6327 case EXEC_OACC_ATOMIC
:
6328 case EXEC_OACC_ROUTINE
: