summaryrefslogtreecommitdiff
path: root/gcc/cppexp.c
diff options
context:
space:
mode:
authorzack <zack@138bc75d-0d04-0410-961f-82ee72b054a4>2001-02-07 18:32:42 +0000
committerzack <zack@138bc75d-0d04-0410-961f-82ee72b054a4>2001-02-07 18:32:42 +0000
commit2376a7f70dbb918445277781cabbd5842467ae9e (patch)
treec4639b8fbbd99fcc0eb642f020f8787aad421122 /gcc/cppexp.c
parentbef2ab2b8e60628b2c39726abbf00189d23565d8 (diff)
downloadgcc-2376a7f70dbb918445277781cabbd5842467ae9e.tar.gz
* 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@39523 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cppexp.c')
-rw-r--r--gcc/cppexp.c38
1 files changed, 28 insertions, 10 deletions
diff --git a/gcc/cppexp.c b/gcc/cppexp.c
index bea20a22ce5..11cde7066e1 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:
{