From 4a3864984cd9d020a65cd2956ed032e3cc254a98 Mon Sep 17 00:00:00 2001 From: Mark Mitchell Date: Thu, 10 Jul 2003 16:47:52 +0000 Subject: [PATCH] re PR c++/10032 (-pedantic converts some errors to warnings) PR c++/10032 * doc/invoke.texi (C++ Dialect Options): Change documentation of -fpermissive. PR c++/10032 * decl.c (cxx_init_decl_processing): With -pedantic, pedwarns are still errors. PR c++/10527 * error.c (decl_to_string): Do not print default argument expressions. * cp-tree.h (break_out_calls): Remove declaration. * tree.c (break_out_calls): Remove. * typeck.c (build_modify_expr): Avoid invalid sharing of trees. PR c++/10032 * g++.dg/warn/pedantic1.C: New test. From-SVN: r69191 --- gcc/ChangeLog | 6 ++ gcc/cp/ChangeLog | 14 +++++ gcc/cp/cp-tree.h | 1 - gcc/cp/decl.c | 2 +- gcc/cp/error.c | 2 +- gcc/cp/tree.c | 80 --------------------------- gcc/cp/typeck.c | 40 +------------- gcc/doc/invoke.texi | 7 +-- gcc/testsuite/ChangeLog | 5 ++ gcc/testsuite/g++.dg/warn/pedantic1.C | 11 ++++ 10 files changed, 43 insertions(+), 125 deletions(-) create mode 100644 gcc/testsuite/g++.dg/warn/pedantic1.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 510512a061f..be28a684dfd 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2003-07-09 Mark Mitchell + + PR c++/10032 + * doc/invoke.texi (C++ Dialect Options): Change documentation of + -fpermissive. + 2003-07-10 J"orn Rennecke * tm.texi (RETURN_ADDR_OFFSET): Document. diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 0f91172fccc..e91e535c18b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,17 @@ +2003-07-09 Mark Mitchell + + PR c++/10032 + * decl.c (cxx_init_decl_processing): With -pedantic, pedwarns are + still errors. + + PR c++/10527 + * error.c (decl_to_string): Do not print default argument + expressions. + + * cp-tree.h (break_out_calls): Remove declaration. + * tree.c (break_out_calls): Remove. + * typeck.c (build_modify_expr): Avoid invalid sharing of trees. + 2003-07-09 Nathan Sidwell PR c++ 9483 diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 58eabc3a396..052c12ab09e 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -4174,7 +4174,6 @@ extern tree build_min (enum tree_code, tree, extern tree build_min_nt (enum tree_code, ...); extern tree build_cplus_new (tree, tree); extern tree get_target_expr (tree); -extern tree break_out_calls (tree); extern tree build_cplus_method_type (tree, tree, tree); extern tree build_cplus_staticfn_type (tree, tree, tree); extern tree build_cplus_array_type (tree, tree); diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 8ed521341d4..966da3ca704 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -6213,7 +6213,7 @@ cxx_init_decl_processing (void) current_lang_name = NULL_TREE; /* Adjust various flags based on command-line settings. */ - if (! flag_permissive && ! pedantic) + if (!flag_permissive) flag_pedantic_errors = 1; if (!flag_no_inline) { diff --git a/gcc/cp/error.c b/gcc/cp/error.c index 79803d2dfff..9edf118eee9 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -2169,7 +2169,7 @@ decl_to_string (tree decl, int verbose) || TREE_CODE (decl) == UNION_TYPE || TREE_CODE (decl) == ENUMERAL_TYPE) flags = TFF_CLASS_KEY_OR_ENUM; if (verbose) - flags |= TFF_DECL_SPECIFIERS | TFF_FUNCTION_DEFAULT_ARGUMENTS; + flags |= TFF_DECL_SPECIFIERS; else if (TREE_CODE (decl) == FUNCTION_DECL) flags |= TFF_DECL_SPECIFIERS | TFF_RETURN_TYPE; flags |= TFF_TEMPLATE_HEADER; diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 366ea3ab01a..7f137343686 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -368,86 +368,6 @@ get_target_expr (tree init) return build_target_expr_with_type (init, TREE_TYPE (init)); } -/* Recursively perform a preorder search EXP for CALL_EXPRs, making - copies where they are found. Returns a deep copy all nodes transitively - containing CALL_EXPRs. */ - -tree -break_out_calls (tree exp) -{ - register tree t1, t2 = NULL_TREE; - register enum tree_code code; - register int changed = 0; - register int i; - - if (exp == NULL_TREE) - return exp; - - code = TREE_CODE (exp); - - if (code == CALL_EXPR) - return copy_node (exp); - - /* Don't try and defeat a save_expr, as it should only be done once. */ - if (code == SAVE_EXPR) - return exp; - - switch (TREE_CODE_CLASS (code)) - { - default: - abort (); - - case 'c': /* a constant */ - case 't': /* a type node */ - case 'x': /* something random, like an identifier or an ERROR_MARK. */ - return exp; - - case 'd': /* A decl node */ - return exp; - - case 'b': /* A block node */ - { - /* Don't know how to handle these correctly yet. Must do a - break_out_calls on all DECL_INITIAL values for local variables, - and also break_out_calls on all sub-blocks and sub-statements. */ - abort (); - } - return exp; - - case 'e': /* an expression */ - case 'r': /* a reference */ - case 's': /* an expression with side effects */ - for (i = TREE_CODE_LENGTH (code) - 1; i >= 0; i--) - { - t1 = break_out_calls (TREE_OPERAND (exp, i)); - if (t1 != TREE_OPERAND (exp, i)) - { - exp = copy_node (exp); - TREE_OPERAND (exp, i) = t1; - } - } - return exp; - - case '<': /* a comparison expression */ - case '2': /* a binary arithmetic expression */ - t2 = break_out_calls (TREE_OPERAND (exp, 1)); - if (t2 != TREE_OPERAND (exp, 1)) - changed = 1; - case '1': /* a unary arithmetic expression */ - t1 = break_out_calls (TREE_OPERAND (exp, 0)); - if (t1 != TREE_OPERAND (exp, 0)) - changed = 1; - if (changed) - { - if (TREE_CODE_LENGTH (code) == 1) - return build1 (code, TREE_TYPE (exp), t1); - else - return build (code, TREE_TYPE (exp), t1, t2); - } - return exp; - } - -} /* Construct, lay out and return the type of methods belonging to class BASETYPE and whose arguments are described by ARGTYPES and whose values diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 189bda2dd35..58055eca08b 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -5399,44 +5399,8 @@ build_modify_expr (tree lhs, enum tree_code modifycode, tree rhs) if (newrhs == error_mark_node) return error_mark_node; - if (TREE_CODE (newrhs) == COND_EXPR) - { - tree lhs1; - tree cond = TREE_OPERAND (newrhs, 0); - - if (TREE_SIDE_EFFECTS (lhs)) - cond = build_compound_expr (tree_cons - (NULL_TREE, lhs, - build_tree_list (NULL_TREE, cond))); - - /* Cannot have two identical lhs on this one tree (result) as preexpand - calls will rip them out and fill in RTL for them, but when the - rtl is generated, the calls will only be in the first side of the - condition, not on both, or before the conditional jump! (mrs) */ - lhs1 = break_out_calls (lhs); - - if (lhs == lhs1) - /* If there's no change, the COND_EXPR behaves like any other rhs. */ - result = build (modifycode == NOP_EXPR ? MODIFY_EXPR : INIT_EXPR, - lhstype, lhs, newrhs); - else - { - tree result_type = TREE_TYPE (newrhs); - /* We have to convert each arm to the proper type because the - types may have been munged by constant folding. */ - result - = build (COND_EXPR, result_type, cond, - build_modify_expr (lhs, modifycode, - cp_convert (result_type, - TREE_OPERAND (newrhs, 1))), - build_modify_expr (lhs1, modifycode, - cp_convert (result_type, - TREE_OPERAND (newrhs, 2)))); - } - } - else - result = build (modifycode == NOP_EXPR ? MODIFY_EXPR : INIT_EXPR, - lhstype, lhs, newrhs); + result = build (modifycode == NOP_EXPR ? MODIFY_EXPR : INIT_EXPR, + lhstype, lhs, newrhs); TREE_SIDE_EFFECTS (result) = 1; diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index bd491347203..83c2354d151 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -1414,10 +1414,9 @@ a name having multiple meanings within a class. @item -fpermissive @opindex fpermissive -Downgrade messages about nonconformant code from errors to warnings. By -default, G++ effectively sets @option{-pedantic-errors} without -@option{-pedantic}; this option reverses that. This behavior and this -option are superseded by @option{-pedantic}, which works as it does for GNU C@. +Downgrade some diagnostics about nonconformant code from errors to +warnings. Thus, using @option{-fpermissive} will allow some +nonconforming code to compile. @item -frepo @opindex frepo diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 491e8b4f382..100c0edf7c9 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2003-07-10 Mark Mitchell + + PR c++/10032 + * g++.dg/warn/pedantic1.C: New test. + 2003-07-10 Nathan Sidwell PR c++ 9483 diff --git a/gcc/testsuite/g++.dg/warn/pedantic1.C b/gcc/testsuite/g++.dg/warn/pedantic1.C new file mode 100644 index 00000000000..2a4d05536c5 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/pedantic1.C @@ -0,0 +1,11 @@ +// PR10032 +// { dg-options "-pedantic" } + +int main() { + goto label; // { dg-error "" } + + int temp = 1; // { dg-error "" } + + label: // { dg-error "" } + return 1; +} -- 2.30.2