Hi, On Tue, 27 Sep 2016, Marek Polacek wrote:
> > Perhaps we want -Wimplicit-fallthrough{,=1,=2,=3,=4}, where =1 would > > match indeed /fall.*thr/i (note, it will be really costly in this > > case, one will have to parse all comments in detail in the > > preprocessor, so I'd be against making it the default), > > Perhaps we could use POSIX regcomp/regex functions; do you (or anyone > else) have an idea how expensive they are and if it's feasible to use > them in the preprocessor? Why? The regexp I gave was for demonstration. Matching /fall.*thr/i would be done by something similar to: a = strcasestr(comment, "fall"); if (!a) return; // no fall b = strcasestr(a+4, "thr"); if (!b) return; // no thr if (memchr(a+4, '\n', b-a-4)) return; // on different lines foundit(); (With appropriate massaging that the comment to parse ends with 0. strcasestr would need addition to libiberty for where it's not available (or falling back to strstr there); obviously the above can be sped up by various tricks for ASCII and UTF-8 because of the relation of upper and lower case characters. During tokenizing the comment (i.e. while searching for the end) one could already search for "fall" for instance to quickly early-out.) Ciao, Michael.