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
This commit is contained in:
Mark Mitchell 2003-07-10 16:47:52 +00:00 committed by Mark Mitchell
parent 1e60c0577d
commit 4a3864984c
10 changed files with 43 additions and 125 deletions

View File

@ -1,3 +1,9 @@
2003-07-09 Mark Mitchell <mark@codesourcery.com>
PR c++/10032
* doc/invoke.texi (C++ Dialect Options): Change documentation of
-fpermissive.
2003-07-10 J"orn Rennecke <joern.rennecke@superh.com>
* tm.texi (RETURN_ADDR_OFFSET): Document.

View File

@ -1,3 +1,17 @@
2003-07-09 Mark Mitchell <mark@codesourcery.com>
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 <nathan@codesourcery.com>
PR c++ 9483

View File

@ -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);

View File

@ -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)
{

View File

@ -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;

View File

@ -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

View File

@ -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;

View File

@ -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

View File

@ -1,3 +1,8 @@
2003-07-10 Mark Mitchell <mark@codesourcery.com>
PR c++/10032
* g++.dg/warn/pedantic1.C: New test.
2003-07-10 Nathan Sidwell <nathan@codesourcery.com>
PR c++ 9483

View File

@ -0,0 +1,11 @@
// PR10032
// { dg-options "-pedantic" }
int main() {
goto label; // { dg-error "" }
int temp = 1; // { dg-error "" }
label: // { dg-error "" }
return 1;
}