From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by sourceware.org (Postfix) with ESMTPS id 374D13857C4A for ; Sun, 16 Aug 2020 09:13:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 374D13857C4A Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=andrew.burgess@embecosm.com Received: by mail-wm1-x344.google.com with SMTP id 3so11472724wmi.1 for ; Sun, 16 Aug 2020 02:13:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=7dyWOgtj1JdmYDCD7R1z+Hehtiw90lInHotx6Ffs8Fc=; b=E8hk5f7iWAXXsaiTCcqtv9jM9VRR70dEB9b4miCv39g5rec/FH1RZxIFT8ofEqeMAc 7wR9UJSU7yKx53FwW5fMMmaRKATtXEmygout4p11i+EMeZsh84+OU7RKWC346cqAox3j wuzXF2bAy2xetKzGDWazr90mPx/vxNSaqE9tcoZxbtUCJBzyiC3o6FgQSpl56kX9y0cr js1xgMgEg184N5bjqqykOsV1Ia71shJENFtE3Kxx0VxTRs238e2jACfR84Dz6QtAVBsW A8/kWRXQbQnjQ99OFezbZMLNgzuhkfgj+RbhK5nn3BsRHePujTiWkHINgkvRMMW1A/Ym rmuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=7dyWOgtj1JdmYDCD7R1z+Hehtiw90lInHotx6Ffs8Fc=; b=ptj6LNS2503fkNvuGbgaO6j7VPLqsm/7Mtwjs8ngqWHq1VgHOb7F/j6LGSvQ4hDr4r TdHerCr5M9KYsxuEZj5mjI4DBqLFH4OJndO31Pb3N7UEashdy8BegOhnUbyotPy8h2Tm Z39xjfiM6XfdVB7Tia8l5qBAnKdaCNePrx2XRdsrI3zlWikRmhkA6uuOO5lx9lIvWVs1 LEN8Hw0kd8C5wDu3NjoGD6SfWaafVZnGQM1y+5ONt+oqJ3OAFLd2Gufc5Y3C8hJIVw8N oxF8lfOSBFBg2VREHmfVhi0CQiCEhst34sUlEvD/iEjYuWM0sgYs8r05dnnGqZmV39WE 4gYQ== X-Gm-Message-State: AOAM530c5jNfp6ZSWBuQrjnmXBTynwff183wdUA2t5vNS1n4hH1pEAsP O/iYBSjdqLFFnI91sFmqUwUGGA== X-Google-Smtp-Source: ABdhPJy1eHyp1VJqCKnZx66bIHGT9dkqdjqEuWV6A/zq6YeVtXBJZ5UJoJMRcAU9mEktOmYKKKoLHw== X-Received: by 2002:a1c:ab8b:: with SMTP id u133mr9599869wme.108.1597569199341; Sun, 16 Aug 2020 02:13:19 -0700 (PDT) Received: from localhost (host86-186-80-213.range86-186.btcentralplus.com. [86.186.80.213]) by smtp.gmail.com with ESMTPSA id o7sm25869514wrv.50.2020.08.16.02.13.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Aug 2020 02:13:18 -0700 (PDT) Date: Sun, 16 Aug 2020 10:13:18 +0100 From: Andrew Burgess To: Tom Tromey Cc: gdb-patches@sourceware.org Subject: Re: [PATCH 1/8] gdbsupport: Provide global operators |=, &=, and ^= for enum bit flags Message-ID: <20200816091318.GI853475@embecosm.com> References: <8eb7f409ca572c526de08ab23878be905f5fef42.1597319264.git.andrew.burgess@embecosm.com> <87a6yvhls1.fsf@tromey.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87a6yvhls1.fsf@tromey.com> X-Operating-System: Linux/5.6.15-200.fc31.x86_64 (x86_64) X-Uptime: 10:08:50 up 28 days, 18:23, X-Editor: GNU Emacs [ http://www.gnu.org/software/emacs ] X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Aug 2020 09:13:22 -0000 * Tom Tromey [2020-08-15 11:16:46 -0600]: > >>>>> "Andrew" == Andrew Burgess writes: > > Andrew> The current enum bit flags mechanism provides global operators &, |, > Andrew> ^, ~, but does not provide &=, |=, ^=. > > Andrew> The implementation for one of these, |=, would look like this: > > Andrew> template > Andrew> typename enum_flags_type::type & > Andrew> operator|= (enum_type &e1, enum_type e2) > > Why "enum_type &e1" and not "enum_flags_type::type &e1" here? > > Andrew> DEF_ENUM_FLAGS_TYPE(enum some_flag, some_flags); > > Andrew> enum some_flag f = flag_val1 | flag_val2; > Andrew> f |= flag_val3; > > To me this example looks incorrect -- the idea behind enum flags is to > not use the "enum some_flag" type, but instead the wrapper. So it > should be: > > some_flags f = flag_val1 | flag_val2; > f |= flag_val3; > > Could you say why you want to use the enum type instead? That would > help me understand this patch. Thanks for the feedback. I believe that I was trying to make the header work with existing code in GDB where 'enum' is used. I'll double check this (I wrote this patch a long time ago now), but if this is the case then, based on your comments, I suspect the "correct" fix is to patch GDB to remove the use of 'enum' (in those places where 'DEF_ENUM_FLAGS_TYPE' is used), and then add the extra operators I need. I'll update this patch and repost. I don't think this should impact the rest of this series in any significant way. Thanks, Andrew