From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25779 invoked by alias); 11 Dec 2013 15:03:13 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 25725 invoked by uid 89); 11 Dec 2013 15:03:13 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-oa0-f44.google.com Received: from Unknown (HELO mail-oa0-f44.google.com) (209.85.219.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Wed, 11 Dec 2013 15:03:12 +0000 Received: by mail-oa0-f44.google.com with SMTP id m1so7375860oag.17 for ; Wed, 11 Dec 2013 07:03:03 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.60.150.238 with SMTP id ul14mr1436305oeb.28.1386774183532; Wed, 11 Dec 2013 07:03:03 -0800 (PST) Received: by 10.182.162.36 with HTTP; Wed, 11 Dec 2013 07:03:03 -0800 (PST) Date: Wed, 11 Dec 2013 15:03:00 -0000 Message-ID: Subject: replace do-while macros with static inline functions From: Prathamesh Kulkarni To: gcc@gcc.gnu.org Content-Type: text/plain; charset=ISO-8859-1 X-IsSubscribed: yes X-SW-Source: 2013-12/txt/msg00148.txt.bz2 I was wondering if it was a good idea to replace do-while macros with static inline functions returning void, where appropriate ? By "where appropriate" I mean: a) call to macro contains no side-effects b) macro does not modify the arguments. c) macro does not use any preprocessor operators (like ##) d) macro does not get undefined or is conditionally defined. e) macro is not type independent (use inline template for these?) f) Any other case ? Example: Consider C_EXPR_APPEND macro defined in c-tree.h: /* Append a new c_expr_t element to V. */ #define C_EXPR_APPEND(V, ELEM) \ do { \ c_expr_t __elem = (ELEM); \ vec_safe_push (V, __elem); \ } while (0) It is called at two places in c-parser.c: 0 c-parser.c 6140 C_EXPR_APPEND (cexpr_list, expr); 1 c-parser.c 6145 C_EXPR_APPEND (cexpr_list, expr); Shall be replaced by: static inline void C_EXPR_APPEND( vec * V, c_expr_t ELEM) { vec_safe_push(V, ELEM); } I will volunteer to do it, if it's accepted. Thanks and Regards, Prathamesh