This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
This pair of patches removes the use of TREE_COMPLEXITY for C and C++. It doesn't get rid of TREE_COMPLEXITY altogether, since I hadn't realised that Java was still using it but using the complexity field directly rather than through the TREE_COMPLEXITY accessor. Thus, Java and Ada are left as the only users of this field. The first patch is Steven Bosscher's patch <http://gcc.gnu.org/ml/gcc-patches/2004-06/msg00863.html> for uses in C++, updated to apply to current mainline. The second patch removes TREE_COMPLEXITY from the C front end and makes the necessary associated changes to the C++ front end to bring -Wparentheses back to an approximately working state (it having been broken by the new C++ parser). This is the one for which the log is below. The approach used for most of the C front end -Wparentheses warnings is that I previously proposed (references in <http://gcc.gnu.org/ml/gcc-patches/2004-06/msg01219.html> in the discussion of the first patch). The parser structures are intended incrementally to move further into the front end. In particular implementation of proper constant expression rules will follow once I've written down the necessary four formal models for what should be implemented for C90, C99 and the GNU extended versions thereof. The approach for warnings for assignments used as truth-values is TREE_NO_WARNING as in the first patch. For C++ this is clearly imperfect as assignments can yield many sorts of tree other than MODIFY_EXPR and so not trigger the warning. At present a proper implementation for C++ would require moving the warning out of c_common_truthvalue_conversion into language-specific code for each front end, called at the syntactically appropriate points. This pair of patches together has been bootstrapped with no regressions on i686-pc-linux-gnu. There is a 0.6% compile-time improvement for building a set of .i files of cc1 at -O0 (note this timing is with --enable-checking compilers), probably because parenthesised expressions and expression statements no longer all get encapsulated in garbage TREE_LISTs. I don't know what further improvement getting rid of the complexity field from tree_exp will bring. Accordingly I request review of (a) patch 1, so Steven Bosscher can apply that; (b) the C++ and Objective-C parts of patch 2. If there are objections to the C++ changes, I'll rework things so that c-common.c doesn't attempt to give the warning for assignments used as truth-values for C++ (the status quo being that C_EXP_ORIGINAL_CODE is never set to MODIFY_EXPR by the current C++ parser, so this warning never happens for C++) so the C++ front end doesn't need changes beyond removing all references to TREE_COMPLEXITY / C_EXP_ORIGINAL_CODE, and file a bug report for the regression in -Wparentheses support in C++ to record the issue. (I should probably file such a bug report anyway for the regression in 3.4.) -- Joseph S. Myers http://www.srcf.ucam.org/~jsm28/gcc/ jsm@polyomino.org.uk (personal mail) jsm28@gcc.gnu.org (Bugzilla assignments and CCs) 2004-07-18 Joseph S. Myers <jsm@polyomino.org.uk> * c-tree.h (struct c_expr): Define. (C_SET_EXP_ORIGINAL_CODE): Remove. (parser_build_binary_op, build_compound_expr): Update prototypes. * c-parse.in (%union): Add exprtype. (FUNC_NAME): Mark as ttype. (expr, expr_no_commas, cast_expr, unary_expr, primary): Change to exprtype. (expr): Update. Define directly in terms of expr_no_commas instead of using nonnull_exprlist. (nonnull_exprlist, unary_expr, cast_expr, expr_no_commas, primary, offsetof_member_designator, typespec_nonreserved_nonattr, init, initval, designator, component_declarator, component_notype_declarator, enumerator, array_declarator, condition, exexpr, switch_statement, stmt_nocomp, stmt, nonnull_asm_operands, ivar_declarator, receiver): Update. Don't set C_EXP_ORIGINAL_CODE. Use TREE_NO_WARNING for assignments where appropriate. * c-common.h (C_EXP_ORIGINAL_CODE): Remove. * c-common.c (c_common_truthvalue_conversion): Don't check C_EXP_ORIGINAL_CODE. * c-typeck.c (parser_build_binary_op): Use c_expr structures. Don't use C_EXP_ORIGINAL_CODE. (default_conversion, default_function_array_conversion): Don't use C_EXP_ORIGINAL_CODE. Preserve TREE_NO_WARNING. (internal_build_compound_expr): Merge into build_compound_expr. (build_compound_expr): Take two operands instead of a TREE_LIST. * objc/objc-act.c (get_super_receiver): Update calls to build_compound_expr. cp: 2004-07-18 Joseph S. Myers <jsm@polyomino.org.uk> * typeck.c (build_modify_expr, build_x_modify_expr): Set TREE_NO_WARNING on assignments with an operator other than '='. testsuite: 2004-07-18 Joseph S. Myers <jsm@polyomino.org.uk> * g++.dg/warn/Wparentheses-1.C, g++.dg/warn/Wparentheses-2.C, gcc.dg/Wparentheses-10.c: New tests. * gcc.dg/Wparentheses-5.c: Remove XFAILs.
Attachment:
bosscher-updated-patch
Description: Text document
Attachment:
cexp-patch
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |