/* CPP Library. (Directive handling.)
- Copyright (C) 1986-2014 Free Software Foundation, Inc.
+ Copyright (C) 1986-2015 Free Software Foundation, Inc.
Contributed by Per Bothner, 1994-95.
Based on CCCP program by Paul Rubin, June 1986
Adapted to ANSI C, Richard Stallman, Jan 1987
if (no_expand)
pfile->state.prevent_expansion++;
- _cpp_scan_out_logical_line (pfile, NULL);
+ _cpp_scan_out_logical_line (pfile, NULL, false);
if (no_expand)
pfile->state.prevent_expansion--;
static void
do_line (cpp_reader *pfile)
{
- const struct line_maps *line_table = pfile->line_table;
+ struct line_maps *line_table = pfile->line_table;
const struct line_map *map = LINEMAPS_LAST_ORDINARY_MAP (line_table);
/* skip_rest_of_line() may cause line table to be realloc()ed so note down
skip_rest_of_line (pfile);
_cpp_do_file_change (pfile, LC_RENAME_VERBATIM, new_file, new_lineno,
map_sysp);
+ line_table->seen_line_directive = true;
}
/* Interpret the # 44 "file" [flags] notation, which has slightly
static void
do_linemarker (cpp_reader *pfile)
{
- const struct line_maps *line_table = pfile->line_table;
+ struct line_maps *line_table = pfile->line_table;
const struct line_map *map = LINEMAPS_LAST_ORDINARY_MAP (line_table);
const cpp_token *token;
const char *new_file = ORDINARY_MAP_FILE_NAME (map);
pfile->line_table->highest_location--;
_cpp_do_file_change (pfile, reason, new_file, new_lineno, new_sysp);
+ line_table->seen_line_directive = true;
}
/* Arrange the file_change callback. pfile->line has changed to
}
ifs->type = T_ELIF;
- if (! ifs->was_skipping)
+ /* See DR#412: "Only the first group whose control condition
+ evaluates to true (nonzero) is processed; any following groups
+ are skipped and their controlling directives are processed as
+ if they were in a group that is skipped." */
+ if (ifs->skip_elses)
+ pfile->state.skipping = 1;
+ else
{
- bool value;
- /* The standard mandates that the expression be parsed even
- if we are skipping elses at this point -- the lexical
- restrictions on #elif only apply to skipped groups, but
- this group is not being skipped. Temporarily set
- skipping to false to get lexer warnings. */
- pfile->state.skipping = 0;
- value = _cpp_parse_expr (pfile, false);
- if (ifs->skip_elses)
- pfile->state.skipping = 1;
- else
- {
- pfile->state.skipping = ! value;
- ifs->skip_elses = value;
- }
+ pfile->state.skipping = ! _cpp_parse_expr (pfile, false);
+ ifs->skip_elses = ! pfile->state.skipping;
}
/* Invalidate any controlling macro. */