diff options
author | Mark Mitchell <mark@codesourcery.com> | 2005-03-22 23:11:31 +0000 |
---|---|---|
committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 2005-03-22 23:11:31 +0000 |
commit | 8ff24a798e576cd22463248fb6975b5b58fd094e (patch) | |
tree | f55ddbeed98ae2cc0f504faf58d52b45f88cd90f /gcc/cp | |
parent | 0dc8f32738b22686e14d8eb32ffcb05c10cb28dd (diff) | |
download | gcc-8ff24a798e576cd22463248fb6975b5b58fd094e.zip gcc-8ff24a798e576cd22463248fb6975b5b58fd094e.tar.gz gcc-8ff24a798e576cd22463248fb6975b5b58fd094e.tar.bz2 |
extend.texi: Deprecate C++ min/max operators.
* doc/extend.texi: Deprecate C++ min/max operators.
* parser.c (cp_parser_warn_min_max): New function.
(cp_parser_binary_expression): Use it.
(cp_parser_assignment_operator_opt): Likewise.
(cp_parser_operator): Likewise.
* g++.dg/opt/max1.C: Run with -Wno-deprecated.
* g++.dg/opt/pr7503-2.C: Likewise.
* g++.dg/opt/pr7503-3.C: Likewise.
* g++.dg/opt/pr7503-4.C: Likewise.
* g++.dg/opt/pr7503-5.C: Likewise.
* g++.dg/warn/minmax.C: New test.
From-SVN: r96899
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/cp/parser.c | 19 |
2 files changed, 26 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 73dd59f..237fe33 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2005-03-22 Mark Mitchell <mark@codesourcery.com> + + * parser.c (cp_parser_warn_min_max): New function. + (cp_parser_binary_expression): Use it. + (cp_parser_assignment_operator_opt): Likewise. + (cp_parser_operator): Likewise. + 2005-03-22 Volker Reichelt <reichelt@igpm.rwth-aachen.de> PR c++/19980 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index a614540..d682f3a 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -1787,6 +1787,16 @@ cp_parser_is_keyword (cp_token* token, enum rid keyword) return token->keyword == keyword; } +/* A minimum or maximum operator has been seen. As these are + deprecated, issue a warning. */ + +static inline void +cp_parser_warn_min_max (void) +{ + if (warn_deprecated && !in_system_header) + warning ("minimum/maximum operators are deprecated"); +} + /* If not parsing tentatively, issue a diagnostic of the form FILE:LINE: MESSAGE before TOKEN where TOKEN is the next token in the input stream. MESSAGE @@ -5401,6 +5411,9 @@ cp_parser_binary_expression (cp_parser* parser, bool cast_p) { /* Get an operator token. */ token = cp_lexer_peek_token (parser->lexer); + if (token->type == CPP_MIN || token->type == CPP_MAX) + cp_parser_warn_min_max (); + new_prec = TOKEN_PRECEDENCE (token); /* Popping an entry off the stack means we completed a subexpression: @@ -5656,10 +5669,12 @@ cp_parser_assignment_operator_opt (cp_parser* parser) case CPP_MIN_EQ: op = MIN_EXPR; + cp_parser_warn_min_max (); break; case CPP_MAX_EQ: op = MAX_EXPR; + cp_parser_warn_min_max (); break; default: @@ -8039,18 +8054,22 @@ cp_parser_operator (cp_parser* parser) /* Extensions. */ case CPP_MIN: id = ansi_opname (MIN_EXPR); + cp_parser_warn_min_max (); break; case CPP_MAX: id = ansi_opname (MAX_EXPR); + cp_parser_warn_min_max (); break; case CPP_MIN_EQ: id = ansi_assopname (MIN_EXPR); + cp_parser_warn_min_max (); break; case CPP_MAX_EQ: id = ansi_assopname (MAX_EXPR); + cp_parser_warn_min_max (); break; default: |