cppexp.c (lex, [...]): Update warning about defined.
* cppexp.c (lex, parse_defined): Update warning about defined. * gcc.dg/cpp/defined.c: Update. From-SVN: r46794
This commit is contained in:
parent
a5356269d3
commit
63d7500569
|
@ -1,3 +1,7 @@
|
||||||
|
2001-11-05 Neil Booth <neil@cat.daikokuya.demon.co.uk>
|
||||||
|
|
||||||
|
* cppexp.c (lex, parse_defined): Update warning about defined.
|
||||||
|
|
||||||
2001-11-05 Geoffrey Keating <geoffk@redhat.com>
|
2001-11-05 Geoffrey Keating <geoffk@redhat.com>
|
||||||
|
|
||||||
* config/rs6000/rs6000.c (rs6000_select_section): Handle
|
* config/rs6000/rs6000.c (rs6000_select_section): Handle
|
||||||
|
|
11
gcc/cppexp.c
11
gcc/cppexp.c
|
@ -219,6 +219,7 @@ parse_defined (pfile)
|
||||||
cpp_hashnode *node = 0;
|
cpp_hashnode *node = 0;
|
||||||
const cpp_token *token;
|
const cpp_token *token;
|
||||||
struct op op;
|
struct op op;
|
||||||
|
cpp_context *initial_context = pfile->context;
|
||||||
|
|
||||||
/* Don't expand macros. */
|
/* Don't expand macros. */
|
||||||
pfile->state.prevent_expansion++;
|
pfile->state.prevent_expansion++;
|
||||||
|
@ -259,6 +260,9 @@ parse_defined (pfile)
|
||||||
op.op = CPP_ERROR;
|
op.op = CPP_ERROR;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (pfile->context != initial_context)
|
||||||
|
cpp_warning (pfile, "this use of \"defined\" may not be portable");
|
||||||
|
|
||||||
op.value = node->type == NT_MACRO;
|
op.value = node->type == NT_MACRO;
|
||||||
op.unsignedp = 0;
|
op.unsignedp = 0;
|
||||||
op.op = CPP_NUMBER;
|
op.op = CPP_NUMBER;
|
||||||
|
@ -314,12 +318,7 @@ lex (pfile, skip_evaluation)
|
||||||
|
|
||||||
case CPP_NAME:
|
case CPP_NAME:
|
||||||
if (token->val.node == pfile->spec_nodes.n_defined)
|
if (token->val.node == pfile->spec_nodes.n_defined)
|
||||||
{
|
return parse_defined (pfile);
|
||||||
if (pfile->context->prev && CPP_PEDANTIC (pfile))
|
|
||||||
cpp_pedwarn (pfile, "\"defined\" operator appears during macro expansion");
|
|
||||||
|
|
||||||
return parse_defined (pfile);
|
|
||||||
}
|
|
||||||
else if (CPP_OPTION (pfile, cplusplus)
|
else if (CPP_OPTION (pfile, cplusplus)
|
||||||
&& (token->val.node == pfile->spec_nodes.n_true
|
&& (token->val.node == pfile->spec_nodes.n_true
|
||||||
|| token->val.node == pfile->spec_nodes.n_false))
|
|| token->val.node == pfile->spec_nodes.n_false))
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
2001-11-05 Neil Booth <neil@cat.daikokuya.demon.co.uk>
|
||||||
|
|
||||||
|
* gcc.dg/cpp/defined.c: Update.
|
||||||
|
|
||||||
2001-11-04 Neil Booth <neil@cat.daikokuya.demon.co.uk>
|
2001-11-04 Neil Booth <neil@cat.daikokuya.demon.co.uk>
|
||||||
|
|
||||||
* gcc.c-torture/execute/anon-1.c: New test.
|
* gcc.c-torture/execute/anon-1.c: New test.
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
/* The behaviour of "defined" when it comes from a macro expansion is
|
/* The behaviour of "defined" when it comes from a macro expansion is
|
||||||
now documented. */
|
now documented. */
|
||||||
#if is_Z_defined /* { dg-warning "macro expansion" } */
|
#if is_Z_defined
|
||||||
#error Macro expanding into defined operator test 1
|
#error Macro expanding into defined operator test 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@
|
||||||
#error Z is defined
|
#error Z is defined
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !is_Z_defined /* { dg-warning "macro expansion" } */
|
#if !is_Z_defined
|
||||||
#error Macro expanding into defined operator test 2
|
#error Macro expanding into defined operator test 2
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@
|
||||||
|
|
||||||
/* The behaviour of "defined" when it comes from a macro expansion is
|
/* The behaviour of "defined" when it comes from a macro expansion is
|
||||||
now documented. */
|
now documented. */
|
||||||
#if is_Z_defined /* { dg-warning "macro expansion" } */
|
#if is_Z_defined
|
||||||
#error Macro expanding into defined operator test 1
|
#error Macro expanding into defined operator test 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -63,6 +63,23 @@
|
||||||
#error Z is defined
|
#error Z is defined
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !is_Z_defined /* { dg-warning "macro expansion" } */
|
#if !is_Z_defined
|
||||||
#error Macro expanding into defined operator test 2
|
#error Macro expanding into defined operator test 2
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Use of defined in different contexts. */
|
||||||
|
|
||||||
|
#define bad1 defined
|
||||||
|
#if !bad1 Z /* { dg-warning "may not be portable" } */
|
||||||
|
#error Z is defined
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !bad1 (Z) /* { dg-warning "may not be portable" } */
|
||||||
|
#error Z is defined
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define bad2 defined (Z
|
||||||
|
#if !bad2) /* { dg-warning "may not be portable" } */
|
||||||
|
#error Z is defined
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue