Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp2765953ima; Mon, 22 Oct 2018 15:48:12 -0700 (PDT) X-Google-Smtp-Source: ACcGV62o93PBUKcelYZzx7YAXDEjFnJWX4oQOd2J/+ZHTylMJeoPwkIZ35L2bGiboch0kk39dzdS X-Received: by 2002:a62:34c5:: with SMTP id b188-v6mr45436940pfa.65.1540248492099; Mon, 22 Oct 2018 15:48:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540248492; cv=none; d=google.com; s=arc-20160816; b=rvs4DmTMrvsIMJj+bkagCqm3f+GCY5Vm0NB6Ddh7pSAV0P1NPT/Qv1tcmHkPzBoqU1 eACfLt9FzkxufZHHtTa61dEkiC5gWFFLGPCcodt5p3iZHejFs47+TCYZZ14k8+8yswNh e23dOCo7dZqbgk1+zwxX+af9MThX+Es+qX7XLJKApgEC/fgkeoEODKv9DxL4lx5onv2M 7IyDK162BJjT4oAcMSQFSg0rPo5VXkHg4z8UyOZlwqATHmsKuA8Wj7euqHAcumE+njY4 aJL2vN77+Z57BSHTpAlToWvxIWYo6SK9q6VkoZ1RcxSKzjNc0GaR3DnkKwcdmpxnVsAD Iazg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=aA5PzG9j8MlbvCqFbqMudH/mSDUJ54+dkNvas0/8RiU=; b=bS9PnOP8yg9UA2wJ7nDumAVBq+ymirgrL9xDUTjEJLyvi2WMc40vXtWIv9SCbygyjF i2shtcbxhDtmW7kxixub6uiJnyBh4t0+EokKT0MO5p5rId0y7uC4Z6TcLiDhSVVE2svI fAE+EMeIBj4t+W6Xodcl97AZBo+6sKQj6Zrit53T8M/T2FzfaIgY6vgAfDStR3FwE/Qv 5sNi06KUH1g7+7Rw2GGVLslVF8VP4TfW39AQE438iJ+jgqQ96ulkUGwIAYvYxp/mvJGB fERPrlVwhkpXS6wybhgnrARGPUIKwNZVp0+KLhyfRjaxsb6XRHcVCoEF8Pa4KO7pbslA /jXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ilEHMf24; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o1-v6si569912plb.186.2018.10.22.15.47.56; Mon, 22 Oct 2018 15:48:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ilEHMf24; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728630AbeJWFyr (ORCPT + 99 others); Tue, 23 Oct 2018 01:54:47 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:47047 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726038AbeJWFyr (ORCPT ); Tue, 23 Oct 2018 01:54:47 -0400 Received: by mail-lj1-f193.google.com with SMTP id x3-v6so38385599lji.13; Mon, 22 Oct 2018 14:34:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=aA5PzG9j8MlbvCqFbqMudH/mSDUJ54+dkNvas0/8RiU=; b=ilEHMf24/ktfRV+xbxOCyibMtTxVAqVDbicGh29aHsDlp/jkNwRLo5wn/6fHk2vnHk nigQWMBSEO9Vo1nY44xCio2tCBQnCKzLFz9Hw2GW2Sav26cecDazKm+5LJxZyj7MkuaJ NntA3+ncP2v55P/Nms6BHuOKP6QolH/+OOePwA499rVUoRQf9R9EYrqmehmCpubSUJCS lpk2wiPyRJTbbKcnACI+6fEEDWknrY48yMYYuVay9E+/g0iqRxwKStQ9K26BrjvafTNy nwi3PaDgPUpRwXA+11Ryh0/vdDBsmFPFAsr7GoWMt2d+3q7wwQpYM7Xdnq8ZHEj8rYka ejjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=aA5PzG9j8MlbvCqFbqMudH/mSDUJ54+dkNvas0/8RiU=; b=IJNhyMRjat90PTw/vNPUo8baCY+nhBIJYuphlLdcX5smKY5Fz8dm7tAl9I7+qnBP5p hF6Lf4rFWd2W0jFEyRI+0Lce9RV5f7dhYD46Tjk8j+I/CU6OwWfdxFPPxM4hym5qS2TK MV/+pf+oC9ZqSK5ETd7piPAlCyRrgehD62p4JsaIqPzswnm8a529Z9QJsT3ZsLKjPhz9 VSCXylt53sZczAg9CsP8vjweOdfUKeVrhvW3/yYkf4+aH5JUS7JPVB48NfQxEcfRxcbd LudLdELS/XlrxhiArGQOT7NmKS4GCK+j0Upd15tE43QaEtl7JsaN3V7D9qWMvvE73qG+ p/YA== X-Gm-Message-State: ABuFfoguU+7pmodLcp2DspeZrytBRKlnXxOjxF0Y69C0ivjMf+I7UV4b 3ZHg9OyJLRVMxpqRXPCspDE80KCoY2c50UKoeKo= X-Received: by 2002:a2e:5c2:: with SMTP id 185-v6mr629885ljf.127.1540244068349; Mon, 22 Oct 2018 14:34:28 -0700 (PDT) MIME-Version: 1.0 References: <20181021171414.22674-1-miguel.ojeda.sandonis@gmail.com> <20181021171414.22674-2-miguel.ojeda.sandonis@gmail.com> <20181021222712.GI1617@thunk.org> <8fb78062-b6d4-6f2d-d943-44bec6b95ff0@petrovitsch.priv.at> <20181022102743.nua5fgbscyeymzal@mwanda> <1474d995-1b5a-2efb-f077-33eb4a5d9e31@petrovitsch.priv.at> <20181022105314.j6djkrpwbnokhai5@mwanda> <3cbb5345-0270-5575-7563-6ad37d888e42@petrovitsch.priv.at> In-Reply-To: <3cbb5345-0270-5575-7563-6ad37d888e42@petrovitsch.priv.at> From: Miguel Ojeda Date: Mon, 22 Oct 2018 23:34:16 +0200 Message-ID: Subject: Re: [PATCH 1/2] Compiler Attributes: add support for __fallthrough (gcc >= 7.1) To: bernd@petrovitsch.priv.at Cc: Dan , "Ted Ts'o" , Greg KH , linux-kernel , Andreas Dilger , Masahiro Yamada , Michal Marek , Steven Rostedt , Mauro Carvalho Chehab , Olof Johansson , Konstantin Ryabitsev , David Miller , Andrey Ryabinin , Kees Cook , Thomas Gleixner , Ingo Molnar , Paul Lawrence , Sandipan Das , Andrey Konovalov , David Woodhouse , Will Deacon , Philippe Ombredanne , Paul Burton , David Rientjes , Willy Tarreau , Martin Sebor , Christopher Li , Jonathan Corbet , Geert Uytterhoeven , Rasmus Villemoes , Joe Perches , Arnd Bergmann , Dominique Martinet , Stefan Agner , Luc Van Oostenryck , Nick Desaulniers , Andrew Morton , Linus Torvalds , Linux Doc Mailing List , Ext4 Developers List , linux-sparse@vger.kernel.org, linux-kbuild@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 22, 2018 at 7:50 PM Bernd Petrovitsch wrote: > > Hi all! > > On 22/10/18 13:07, Miguel Ojeda wrote: > > On Mon, Oct 22, 2018 at 12:54 PM Dan Carpenter wrote: > >> > >> Doing both is super ugly. Let's just do comments until Eclipse gets > >> updated. > > Yes, "Eclipse" as the IDE. > > And yes but IMHO better super ugly than loosing the warning - YMMV. I think Dan meant too simply not touch anything (i.e. not losing the warning anywhere). > > For the archives: I have Eclipse Photon/June 2016 here. And "no break" > is the (default) string in a comment used by Eclipse (it can be > customized and is actually a regexp but it must be in a comment). > Hm... that means they don't support (by default) the same regexps as GCC; which is bad: it means that it is only equivalent to the most relaxed level in gcc, 1: """ -Wimplicit-fallthrough=1 matches .* regular expression, any comment is used as fallthrough comment. """ See https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html i.e. any other level above will either not match Eclipse or not match gcc. > >> I had wanted to move to the attribute because that would simplify things > >> in Smatch but it's not a huge deal to delay for another year. > > > > I can re-send them later on, no problem. On the other hand, doing the > > changes will push tools to get updated sooner ;-) > > > > If tools were doing something as fancy as comment parsing for > > diagnostics, they should have been updated with the attribute support > > (either gcc's or C++17's) -- it has been more than a year now since > > gcc 7.1 and the C++17 final draft. (Note that this does not apply for > > things like clang, since they weren't doing comment parsing to begin > > with.) > > That would be nice. And if they agree on the same texts (or accept per > default all somewhat widely used and/or old ones). > > After stumbling over > https://stackoverflow.com/questions/16935935/how-do-i-turn-off-a-static-code-analysis-warning-on-a-line-by-line-warning-in-cd, > looking into Eclipses Window -> Preferences -> C/C++ -> Code Analysis -> > "No break at the end of case" screen (that's the screenshot there) and I > tried various things: > > Preface: > I have > ---- snip ---- > #define __fallthrough __attribute__((fallthrough)) > ---- snip ---- > for gcc >= 7 (because clang doesn't know it and I had also older > gcc's in use before). > > So: > - Adding a comment to the #define doesn't change anything for Eclipse. It shouldn't according to the standard -- but who knows... :-) > - Eclipse looks *only* in comments for the string/regexp given > the warnings configuration (and that comment must be on the line > directly before the "case"). > - Eclipse understands [[fallthrough]] out-of-the-box though (which > is C++11 AFAIK) as does g++-7 (I use -std=gnu++17 - most of the > sources are C++, but not all) and clang++-6 (all the current standard > Ubuntu-18.06/Bionic packages). Eclipse understanding [[fallthrough]] is very good, actually. > Eclipse "accepts" [[fallthrough]] only in C++ sources (and not in C > sources). Bad, but I guess they will add it to C eventually, since it is probably coming for C2x. > - Neither gcc nor clang understand [[fallthrough]] (so it's probably a > no-go for the Kernel with C89 anyways). clang does it if you enable -fdouble-square-bracket-attributes (please see my other messages). gcc will at some point (if C2x gets the attributes), but at the moment the C parser is different than the C++ parser and there is no support for it on trunk that I could see, so they will have to copy the support; i.e. it will take a bit more time than clang, likely. Thanks a *lot* for taking a look at Eclipse! Cheers, Miguel