diff options
author | Zack Weinberg <zack@wolery.stanford.edu> | 2001-02-07 18:32:42 +0000 |
---|---|---|
committer | Zack Weinberg <zack@gcc.gnu.org> | 2001-02-07 18:32:42 +0000 |
commit | 7d4918a2d96f1512bd71b00d1deae61fbd4a6ab9 (patch) | |
tree | c4639b8fbbd99fcc0eb642f020f8787aad421122 /gcc/cppexp.c | |
parent | 7acfb19e402f6ec59f2efc0f8fe6d462615f6b5d (diff) | |
download | gcc-7d4918a2d96f1512bd71b00d1deae61fbd4a6ab9.zip gcc-7d4918a2d96f1512bd71b00d1deae61fbd4a6ab9.tar.gz gcc-7d4918a2d96f1512bd71b00d1deae61fbd4a6ab9.tar.bz2 |
cpphash.h (struct spec_nodes): Add n_true and n_false.
* cpphash.h (struct spec_nodes): Add n_true and n_false.
* cppinit.c (cpp_create_reader): Initialize them.
(append_include_chain): cxx_aware arg might be unused.
* cppexp.c (lex): In C++ mode, recognize 'true' and 'false'
keywords and give them their phase 7 meaning. Pedwarn about
this unless '__bool_true_false_are_defined' is defined.
* g++.dg/stdbool-if.C: New test.
From-SVN: r39523
Diffstat (limited to 'gcc/cppexp.c')
-rw-r--r-- | gcc/cppexp.c | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/gcc/cppexp.c b/gcc/cppexp.c index bea20a2..11cde70 100644 --- a/gcc/cppexp.c +++ b/gcc/cppexp.c @@ -426,18 +426,36 @@ lex (pfile, skip_evaluation, token) return parse_defined (pfile); } - /* Controlling #if expressions cannot contain identifiers (they - could become macros in the future). */ - pfile->mi_state = MI_FAILED; - - op.op = CPP_INT; - op.unsignedp = 0; - op.value = 0; + else if (CPP_OPTION (pfile, cplusplus) + && (token->val.node == pfile->spec_nodes.n_true + || token->val.node == pfile->spec_nodes.n_false)) + { + op.op = CPP_INT; + op.unsignedp = 0; + op.value = (token->val.node == pfile->spec_nodes.n_true); + + /* Warn about use of true or false in #if when pedantic + and stdbool.h has not been included. */ + if (CPP_PEDANTIC (pfile) + && ! cpp_defined (pfile, DSC("__bool_true_false_are_defined"))) + cpp_pedwarn (pfile, "ISO C++ does not permit \"%s\" in #if", + token->val.node->name); + return op; + } + else + { + /* Controlling #if expressions cannot contain identifiers (they + could become macros in the future). */ + pfile->mi_state = MI_FAILED; - if (CPP_OPTION (pfile, warn_undef) && !skip_evaluation) - cpp_warning (pfile, "\"%s\" is not defined", token->val.node->name); + op.op = CPP_INT; + op.unsignedp = 0; + op.value = 0; - return op; + if (CPP_OPTION (pfile, warn_undef) && !skip_evaluation) + cpp_warning (pfile, "\"%s\" is not defined", token->val.node->name); + return op; + } case CPP_HASH: { |