diff options
author | mpolacek <mpolacek@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-01-23 11:57:43 +0000 |
---|---|---|
committer | mpolacek <mpolacek@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-01-23 11:57:43 +0000 |
commit | 6ca4fe4677980afdcd800f8406c80a080a4f7267 (patch) | |
tree | b588bb547ecd04e5b2df8f148a1b0e9e0cdc32fc /libcpp/directives.c | |
parent | a96683ba5f8953e220ce120abdd0077a05cb87be (diff) | |
download | linaro-gcc-6ca4fe4677980afdcd800f8406c80a080a4f7267.tar.gz linaro-gcc-6ca4fe4677980afdcd800f8406c80a080a4f7267.tar.bz2 linaro-gcc-6ca4fe4677980afdcd800f8406c80a080a4f7267.zip |
DR#412
PR preprocessor/60570
* directives.c (do_elif): Don't evaluate #elif conditionals
when they don't need to be.
* gcc.dg/cpp/pr36320.c: Turn dg-error into dg-bogus.
* gcc.dg/cpp/pr60570.c: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@220035 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libcpp/directives.c')
-rw-r--r-- | libcpp/directives.c | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/libcpp/directives.c b/libcpp/directives.c index ab4f15c5bd7..37cd109ed8a 100644 --- a/libcpp/directives.c +++ b/libcpp/directives.c @@ -2036,23 +2036,16 @@ do_elif (cpp_reader *pfile) } 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. */ |