mirrored from git://gcc.gnu.org/git/gcc.git
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
/
scanner.cc
2906 lines (2461 loc) · 65.4 KB
/
scanner.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* Character scanner.
Copyright (C) 2000-2024 Free Software Foundation, Inc.
Contributed by Andy Vaught
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
/* Set of subroutines to (ultimately) return the next character to the
various matching subroutines. This file's job is to read files and
build up lines that are parsed by the parser. This means that we
handle continuation lines and "include" lines.
The first thing the scanner does is to load an entire file into
memory. We load the entire file into memory for a couple reasons.
The first is that we want to be able to deal with nonseekable input
(pipes, stdin) and there is a lot of backing up involved during
parsing.
The second is that we want to be able to print the locus of errors,
and an error on line 999999 could conflict with something on line
one. Given nonseekable input, we've got to store the whole thing.
One thing that helps are the column truncation limits that give us
an upper bound on the size of individual lines. We don't store the
truncated stuff.
From the scanner's viewpoint, the higher level subroutines ask for
new characters and do a lot of jumping backwards. */
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "gfortran.h"
#include "toplev.h" /* For set_src_pwd. */
#include "debug.h"
#include "options.h"
#include "diagnostic-core.h" /* For fatal_error. */
#include "cpp.h"
#include "scanner.h"
/* List of include file search directories. */
gfc_directorylist *include_dirs, *intrinsic_modules_dirs;
static gfc_file *file_head, *current_file;
static bool continue_flag, end_flag, gcc_attribute_flag;
/* If !$omp/!$acc occurred in current comment line. */
static int openmp_flag, openacc_flag;
static int continue_count, continue_line;
static locus openmp_locus;
static locus openacc_locus;
static locus gcc_attribute_locus;
gfc_source_form gfc_current_form;
static gfc_linebuf *line_head, *line_tail;
locus gfc_current_locus;
const char *gfc_source_file;
static FILE *gfc_src_file;
static gfc_char_t *gfc_src_preprocessor_lines[2];
static struct gfc_file_change
{
const char *filename;
gfc_linebuf *lb;
int line;
} *file_changes;
static size_t file_changes_cur, file_changes_count;
static size_t file_changes_allocated;
static gfc_char_t *last_error_char;
/* Functions dealing with our wide characters (gfc_char_t) and
sequences of such characters. */
bool
gfc_wide_fits_in_byte (gfc_char_t c)
{
return (c <= UCHAR_MAX);
}
static inline int
wide_is_ascii (gfc_char_t c)
{
return (gfc_wide_fits_in_byte (c) && ((unsigned char) c & ~0x7f) == 0);
}
bool
gfc_wide_is_printable (gfc_char_t c)
{
return (gfc_wide_fits_in_byte (c) && ISPRINT ((unsigned char) c));
}
gfc_char_t
gfc_wide_tolower (gfc_char_t c)
{
return (wide_is_ascii (c) ? (gfc_char_t) TOLOWER((unsigned char) c) : c);
}
gfc_char_t
gfc_wide_toupper (gfc_char_t c)
{
return (wide_is_ascii (c) ? (gfc_char_t) TOUPPER((unsigned char) c) : c);
}
bool
gfc_wide_is_digit (gfc_char_t c)
{
return (c >= '0' && c <= '9');
}
static inline int
wide_atoi (gfc_char_t *c)
{
#define MAX_DIGITS 20
char buf[MAX_DIGITS+1];
int i = 0;
while (gfc_wide_is_digit(*c) && i < MAX_DIGITS)
buf[i++] = *c++;
buf[i] = '\0';
return atoi (buf);
}
size_t
gfc_wide_strlen (const gfc_char_t *str)
{
size_t i;
for (i = 0; str[i]; i++)
;
return i;
}
gfc_char_t *
gfc_wide_memset (gfc_char_t *b, gfc_char_t c, size_t len)
{
size_t i;
for (i = 0; i < len; i++)
b[i] = c;
return b;
}
static gfc_char_t *
wide_strcpy (gfc_char_t *dest, const gfc_char_t *src)
{
gfc_char_t *d;
for (d = dest; (*d = *src) != '\0'; ++src, ++d)
;
return dest;
}
static gfc_char_t *
wide_strchr (const gfc_char_t *s, gfc_char_t c)
{
do {
if (*s == c)
{
return CONST_CAST(gfc_char_t *, s);
}
} while (*s++);
return 0;
}
char *
gfc_widechar_to_char (const gfc_char_t *s, int length)
{
size_t len, i;
char *res;
if (s == NULL)
return NULL;
/* Passing a negative length is used to indicate that length should be
calculated using gfc_wide_strlen(). */
len = (length >= 0 ? (size_t) length : gfc_wide_strlen (s));
res = XNEWVEC (char, len + 1);
for (i = 0; i < len; i++)
{
gcc_assert (gfc_wide_fits_in_byte (s[i]));
res[i] = (unsigned char) s[i];
}
res[len] = '\0';
return res;
}
gfc_char_t *
gfc_char_to_widechar (const char *s)
{
size_t len, i;
gfc_char_t *res;
if (s == NULL)
return NULL;
len = strlen (s);
res = gfc_get_wide_string (len + 1);
for (i = 0; i < len; i++)
res[i] = (unsigned char) s[i];
res[len] = '\0';
return res;
}
static int
wide_strncmp (const gfc_char_t *s1, const char *s2, size_t n)
{
gfc_char_t c1, c2;
while (n-- > 0)
{
c1 = *s1++;
c2 = *s2++;
if (c1 != c2)
return (c1 > c2 ? 1 : -1);
if (c1 == '\0')
return 0;
}
return 0;
}
int
gfc_wide_strncasecmp (const gfc_char_t *s1, const char *s2, size_t n)
{
gfc_char_t c1, c2;
while (n-- > 0)
{
c1 = gfc_wide_tolower (*s1++);
c2 = TOLOWER (*s2++);
if (c1 != c2)
return (c1 > c2 ? 1 : -1);
if (c1 == '\0')
return 0;
}
return 0;
}
/* Main scanner initialization. */
void
gfc_scanner_init_1 (void)
{
file_head = NULL;
line_head = NULL;
line_tail = NULL;
continue_count = 0;
continue_line = 0;
end_flag = 0;
last_error_char = NULL;
}
/* Main scanner destructor. */
void
gfc_scanner_done_1 (void)
{
gfc_linebuf *lb;
gfc_file *f;
while(line_head != NULL)
{
lb = line_head->next;
free (line_head);
line_head = lb;
}
while(file_head != NULL)
{
f = file_head->next;
free (file_head->filename);
free (file_head);
file_head = f;
}
}
static bool
gfc_do_check_include_dir (const char *path, bool warn)
{
struct stat st;
if (stat (path, &st))
{
if (errno != ENOENT)
gfc_warning_now (0, "Include directory %qs: %s",
path, xstrerror(errno));
else if (warn)
gfc_warning_now (OPT_Wmissing_include_dirs,
"Nonexistent include directory %qs", path);
return false;
}
else if (!S_ISDIR (st.st_mode))
{
gfc_fatal_error ("%qs is not a directory", path);
return false;
}
return true;
}
/* In order that -W(no-)missing-include-dirs works, the diagnostic can only be
run after processing the commandline. */
static void
gfc_do_check_include_dirs (gfc_directorylist **list, bool do_warn)
{
gfc_directorylist *prev, *q, *n;
prev = NULL;
n = *list;
while (n)
{
q = n; n = n->next;
if (gfc_do_check_include_dir (q->path, q->warn && do_warn))
{
prev = q;
continue;
}
if (prev == NULL)
*list = n;
else
prev->next = n;
free (q->path);
free (q);
}
}
void
gfc_check_include_dirs (bool verbose_missing_dir_warn)
{
/* This is a bit convoluted: If gfc_cpp_enabled () and
verbose_missing_dir_warn, the warning is shown by libcpp. Otherwise,
it is shown here, still conditional on OPT_Wmissing_include_dirs. */
bool warn = !gfc_cpp_enabled () || !verbose_missing_dir_warn;
gfc_do_check_include_dirs (&include_dirs, warn);
gfc_do_check_include_dirs (&intrinsic_modules_dirs, verbose_missing_dir_warn);
if (gfc_option.module_dir && gfc_cpp_enabled ())
gfc_do_check_include_dirs (&include_dirs, true);
}
/* Adds path to the list pointed to by list. */
static void
add_path_to_list (gfc_directorylist **list, const char *path,
bool use_for_modules, bool head, bool warn, bool defer_warn)
{
gfc_directorylist *dir;
const char *p;
char *q;
size_t len;
int i;
p = path;
while (*p == ' ' || *p == '\t') /* someone might do "-I include" */
if (*p++ == '\0')
return;
/* Strip trailing directory separators from the path, as this
will confuse Windows systems. */
len = strlen (p);
q = (char *) alloca (len + 1);
memcpy (q, p, len + 1);
i = len - 1;
while (i >=0 && IS_DIR_SEPARATOR (q[i]))
q[i--] = '\0';
if (!defer_warn && !gfc_do_check_include_dir (q, warn))
return;
if (head || *list == NULL)
{
dir = XCNEW (gfc_directorylist);
if (!head)
*list = dir;
}
else
{
dir = *list;
while (dir->next)
dir = dir->next;
dir->next = XCNEW (gfc_directorylist);
dir = dir->next;
}
dir->next = head ? *list : NULL;
if (head)
*list = dir;
dir->use_for_modules = use_for_modules;
dir->warn = warn;
dir->path = xstrdup (p);
}
/* defer_warn is set to true while parsing the commandline. */
void
gfc_add_include_path (const char *path, bool use_for_modules, bool file_dir,
bool warn, bool defer_warn)
{
add_path_to_list (&include_dirs, path, use_for_modules, file_dir, warn,
defer_warn);
/* For '#include "..."' these directories are automatically searched. */
if (!file_dir)
gfc_cpp_add_include_path (xstrdup(path), true);
}
void
gfc_add_intrinsic_modules_path (const char *path)
{
add_path_to_list (&intrinsic_modules_dirs, path, true, false, false, false);
}
/* Release resources allocated for options. */
void
gfc_release_include_path (void)
{
gfc_directorylist *p;
while (include_dirs != NULL)
{
p = include_dirs;
include_dirs = include_dirs->next;
free (p->path);
free (p);
}
while (intrinsic_modules_dirs != NULL)
{
p = intrinsic_modules_dirs;
intrinsic_modules_dirs = intrinsic_modules_dirs->next;
free (p->path);
free (p);
}
free (gfc_option.module_dir);
}
static FILE *
open_included_file (const char *name, gfc_directorylist *list,
bool module, bool system)
{
char *fullname;
gfc_directorylist *p;
FILE *f;
for (p = list; p; p = p->next)
{
if (module && !p->use_for_modules)
continue;
fullname = (char *) alloca(strlen (p->path) + strlen (name) + 2);
strcpy (fullname, p->path);
strcat (fullname, "/");
strcat (fullname, name);
f = gfc_open_file (fullname);
if (f != NULL)
{
if (gfc_cpp_makedep ())
gfc_cpp_add_dep (fullname, system);
return f;
}
}
return NULL;
}
/* Opens file for reading, searching through the include directories
given if necessary. If the include_cwd argument is true, we try
to open the file in the current directory first. */
FILE *
gfc_open_included_file (const char *name, bool include_cwd, bool module)
{
FILE *f = NULL;
if (IS_ABSOLUTE_PATH (name) || include_cwd)
{
f = gfc_open_file (name);
if (f && gfc_cpp_makedep ())
gfc_cpp_add_dep (name, false);
}
if (!f)
f = open_included_file (name, include_dirs, module, false);
return f;
}
/* Test to see if we're at the end of the main source file. */
bool
gfc_at_end (void)
{
return end_flag;
}
/* Test to see if we're at the end of the current file. */
bool
gfc_at_eof (void)
{
if (gfc_at_end ())
return 1;
if (line_head == NULL)
return 1; /* Null file */
if (gfc_current_locus.lb == NULL)
return 1;
return 0;
}
/* Test to see if we're at the beginning of a new line. */
bool
gfc_at_bol (void)
{
if (gfc_at_eof ())
return 1;
return (gfc_current_locus.nextc == gfc_current_locus.lb->line);
}
/* Test to see if we're at the end of a line. */
bool
gfc_at_eol (void)
{
if (gfc_at_eof ())
return 1;
return (*gfc_current_locus.nextc == '\0');
}
static void
add_file_change (const char *filename, int line)
{
if (file_changes_count == file_changes_allocated)
{
if (file_changes_allocated)
file_changes_allocated *= 2;
else
file_changes_allocated = 16;
file_changes = XRESIZEVEC (struct gfc_file_change, file_changes,
file_changes_allocated);
}
file_changes[file_changes_count].filename = filename;
file_changes[file_changes_count].lb = NULL;
file_changes[file_changes_count++].line = line;
}
static void
report_file_change (gfc_linebuf *lb)
{
size_t c = file_changes_cur;
while (c < file_changes_count
&& file_changes[c].lb == lb)
{
if (file_changes[c].filename)
(*debug_hooks->start_source_file) (file_changes[c].line,
file_changes[c].filename);
else
(*debug_hooks->end_source_file) (file_changes[c].line);
++c;
}
file_changes_cur = c;
}
void
gfc_start_source_files (void)
{
/* If the debugger wants the name of the main source file,
we give it. */
if (debug_hooks->start_end_main_source_file)
(*debug_hooks->start_source_file) (0, gfc_source_file);
file_changes_cur = 0;
report_file_change (gfc_current_locus.lb);
}
void
gfc_end_source_files (void)
{
report_file_change (NULL);
if (debug_hooks->start_end_main_source_file)
(*debug_hooks->end_source_file) (0);
}
/* Advance the current line pointer to the next line. */
void
gfc_advance_line (void)
{
if (gfc_at_end ())
return;
if (gfc_current_locus.lb == NULL)
{
end_flag = 1;
return;
}
if (gfc_current_locus.lb->next
&& !gfc_current_locus.lb->next->dbg_emitted)
{
report_file_change (gfc_current_locus.lb->next);
gfc_current_locus.lb->next->dbg_emitted = true;
}
gfc_current_locus.lb = gfc_current_locus.lb->next;
if (gfc_current_locus.lb != NULL)
gfc_current_locus.nextc = gfc_current_locus.lb->line;
else
{
gfc_current_locus.nextc = NULL;
end_flag = 1;
}
}
/* Get the next character from the input, advancing gfc_current_file's
locus. When we hit the end of the line or the end of the file, we
start returning a '\n' in order to complete the current statement.
No Fortran line conventions are implemented here.
Requiring explicit advances to the next line prevents the parse
pointer from being on the wrong line if the current statement ends
prematurely. */
static gfc_char_t
next_char (void)
{
gfc_char_t c;
if (gfc_current_locus.nextc == NULL)
return '\n';
c = *gfc_current_locus.nextc++;
if (c == '\0')
{
gfc_current_locus.nextc--; /* Remain on this line. */
c = '\n';
}
return c;
}
/* Skip a comment. When we come here the parse pointer is positioned
immediately after the comment character. If we ever implement
compiler directives within comments, here is where we parse the
directive. */
static void
skip_comment_line (void)
{
gfc_char_t c;
do
{
c = next_char ();
}
while (c != '\n');
gfc_advance_line ();
}
bool
gfc_define_undef_line (void)
{
char *tmp;
/* All lines beginning with '#' are either #define or #undef. */
if (debug_info_level != DINFO_LEVEL_VERBOSE || gfc_peek_ascii_char () != '#')
return 0;
if (wide_strncmp (gfc_current_locus.nextc, "#define ", 8) == 0)
{
tmp = gfc_widechar_to_char (&gfc_current_locus.nextc[8], -1);
(*debug_hooks->define) (gfc_linebuf_linenum (gfc_current_locus.lb),
tmp);
free (tmp);
}
if (wide_strncmp (gfc_current_locus.nextc, "#undef ", 7) == 0)
{
tmp = gfc_widechar_to_char (&gfc_current_locus.nextc[7], -1);
(*debug_hooks->undef) (gfc_linebuf_linenum (gfc_current_locus.lb),
tmp);
free (tmp);
}
/* Skip the rest of the line. */
skip_comment_line ();
return 1;
}
/* Return true if GCC$ was matched. */
static bool
skip_gcc_attribute (locus start)
{
bool r = false;
char c;
locus old_loc = gfc_current_locus;
if ((c = next_char ()) == 'g' || c == 'G')
if ((c = next_char ()) == 'c' || c == 'C')
if ((c = next_char ()) == 'c' || c == 'C')
if ((c = next_char ()) == '$')
r = true;
if (r == false)
gfc_current_locus = old_loc;
else
{
gcc_attribute_flag = 1;
gcc_attribute_locus = old_loc;
gfc_current_locus = start;
}
return r;
}
/* Return true if CC was matched. */
static bool
skip_free_oacc_sentinel (locus start, locus old_loc)
{
bool r = false;
char c;
if ((c = next_char ()) == 'c' || c == 'C')
if ((c = next_char ()) == 'c' || c == 'C')
r = true;
if (r)
{
if ((c = next_char ()) == ' ' || c == '\t'
|| continue_flag)
{
while (gfc_is_whitespace (c))
c = next_char ();
if (c != '\n' && c != '!')
{
openacc_flag = 1;
openacc_locus = old_loc;
gfc_current_locus = start;
}
else
r = false;
}
else
{
gfc_warning_now (0, "!$ACC at %C starts a commented "
"line as it neither is followed "
"by a space nor is a "
"continuation line");
r = false;
}
}
return r;
}
/* Return true if MP was matched. */
static bool
skip_free_omp_sentinel (locus start, locus old_loc)
{
bool r = false;
char c;
if ((c = next_char ()) == 'm' || c == 'M')
if ((c = next_char ()) == 'p' || c == 'P')
r = true;
if (r)
{
if ((c = next_char ()) == ' ' || c == '\t'
|| continue_flag)
{
while (gfc_is_whitespace (c))
c = next_char ();
if (c != '\n' && c != '!')
{
openmp_flag = 1;
openmp_locus = old_loc;
gfc_current_locus = start;
}
else
r = false;
}
else
{
gfc_warning_now (0, "!$OMP at %C starts a commented "
"line as it neither is followed "
"by a space nor is a "
"continuation line");
r = false;
}
}
return r;
}
/* Comment lines are null lines, lines containing only blanks or lines
on which the first nonblank line is a '!'.
Return true if !$ openmp or openacc conditional compilation sentinel was
seen. */
static bool
skip_free_comments (void)
{
locus start;
gfc_char_t c;
int at_bol;
for (;;)
{
at_bol = gfc_at_bol ();
start = gfc_current_locus;
if (gfc_at_eof ())
break;
do
c = next_char ();
while (gfc_is_whitespace (c));
if (c == '\n')
{
gfc_advance_line ();
continue;
}
if (c == '!')
{
/* Keep the !GCC$ line. */
if (at_bol && skip_gcc_attribute (start))
return false;
/* If -fopenmp/-fopenacc, we need to handle here 2 things:
1) don't treat !$omp/!$acc as comments, but directives
2) handle OpenMP conditional compilation, where
!$ should be treated as 2 spaces (for initial lines
only if followed by space). */
if (at_bol)
{
if ((flag_openmp || flag_openmp_simd)
&& flag_openacc)
{
locus old_loc = gfc_current_locus;
if (next_char () == '$')
{
c = next_char ();
if (c == 'o' || c == 'O')
{
if (skip_free_omp_sentinel (start, old_loc))
return false;
gfc_current_locus = old_loc;
next_char ();
c = next_char ();
}
else if (c == 'a' || c == 'A')
{
if (skip_free_oacc_sentinel (start, old_loc))
return false;
gfc_current_locus = old_loc;
next_char ();
c = next_char ();
}
if (continue_flag || c == ' ' || c == '\t')
{
gfc_current_locus = old_loc;
next_char ();
openmp_flag = openacc_flag = 0;
return true;
}
}
gfc_current_locus = old_loc;
}
else if ((flag_openmp || flag_openmp_simd)
&& !flag_openacc)
{
locus old_loc = gfc_current_locus;
if (next_char () == '$')
{
c = next_char ();
if (c == 'o' || c == 'O')
{
if (skip_free_omp_sentinel (start, old_loc))
return false;
gfc_current_locus = old_loc;
next_char ();
c = next_char ();
}
if (continue_flag || c == ' ' || c == '\t')
{
gfc_current_locus = old_loc;
next_char ();
openmp_flag = 0;
return true;
}
}
gfc_current_locus = old_loc;
}
else if (flag_openacc
&& !(flag_openmp || flag_openmp_simd))
{
locus old_loc = gfc_current_locus;
if (next_char () == '$')
{
c = next_char ();
if (c == 'a' || c == 'A')
{
if (skip_free_oacc_sentinel (start, old_loc))
return false;
gfc_current_locus = old_loc;
next_char();
c = next_char();
}
}
gfc_current_locus = old_loc;
}
}
skip_comment_line ();
continue;
}
break;
}
if (openmp_flag && at_bol)
openmp_flag = 0;
if (openacc_flag && at_bol)
openacc_flag = 0;
gcc_attribute_flag = 0;
gfc_current_locus = start;
return false;
}
/* Return true if MP was matched in fixed form. */
static bool
skip_fixed_omp_sentinel (locus *start)
{
gfc_char_t c;
if ((c = next_char ()) != 'm' && c != 'M')
return false;
if ((c = next_char ()) == 'p' || c == 'P')
{
c = next_char ();
if (c != '\n'
&& (continue_flag
|| c == ' ' || c == '\t' || c == '0'))
{
if (c == ' ' || c == '\t' || c == '0')
openacc_flag = 0;
do
c = next_char ();
while (gfc_is_whitespace (c));
if (c != '\n' && c != '!')
{