<div dir="ltr"><div dir="ltr">On Mon, 11 May 2020 at 06:37, Hans Wennborg via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Sat, May 9, 2020 at 4:32 AM Richard Smith via cfe-commits<br>
<<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>> wrote:<br>
><br>
><br>
> Author: Richard Smith<br>
> Date: 2020-05-08T19:32:00-07:00<br>
> New Revision: c90e198107431f64b73686bdce31c293e3380ac7<br>
><br>
> URL: <a href="https://github.com/llvm/llvm-project/commit/c90e198107431f64b73686bdce31c293e3380ac7" rel="noreferrer" target="_blank">https://github.com/llvm/llvm-project/commit/c90e198107431f64b73686bdce31c293e3380ac7</a><br>
> DIFF: <a href="https://github.com/llvm/llvm-project/commit/c90e198107431f64b73686bdce31c293e3380ac7.diff" rel="noreferrer" target="_blank">https://github.com/llvm/llvm-project/commit/c90e198107431f64b73686bdce31c293e3380ac7.diff</a><br>
><br>
> LOG: Fix parsing of enum-base to follow C++11 rules.<br>
><br>
> Previously we implemented non-standard disambiguation rules to<br>
> distinguish an enum-base from a bit-field but otherwise treated a :<br>
> after an elaborated-enum-specifier as introducing an enum-base. That<br>
> misparses various examples (anywhere an elaborated-type-specifier can<br>
> appear followed by a colon, such as within a ternary operator or<br>
> _Generic).<br>
><br>
> We now implement the C++11 rules, with the old cases accepted as<br>
> extensions where that seemed reasonable. These amount to:<br>
>  * an enum-base must always be accompanied by an enum definition (except<br>
>    in a standalone declaration of the form 'enum E : T;')<br>
>  * in a member-declaration, 'enum E :' always introduces an enum-base,<br>
>    never a bit-field<br>
>  * in a type-specifier (or similar context), 'enum E :' is not<br>
>    permitted; the colon means whatever else it would mean in that<br>
>    context.<br>
><br>
> Fixed underlying types for enums are also permitted in Objective-C and<br>
> under MS extensions, plus as a language extension in all other modes.<br>
> The behavior in ObjC and MS extensions modes is unchanged (but the<br>
> bit-field disambiguation is a bit better); remaining language modes<br>
> follow the C++11 rules.<br>
><br>
> Fixes PR45726, PR39979, PR19810, PR44941, and most of PR24297, plus C++<br>
> core issues 1514 and 1966.<br>
<br>
Hello from Chromium :-)<br>
<br>
We saw new errors from some code in a header that looked like this:<br>
<br>
  // Adapted from NSPathUtilities.h and NSObjCRuntime.h.<br>
  typedef enum NSSearchPathDirectory : unsigned long NSSearchPathDirectory;<br>
<br>
For us we think the enum itself is enough, so we'll fix it by dropping<br>
the typedef, but this raised the question of how your change affects<br>
the Mac system headers. IIUC your change makes an exception for Obj-C,<br>
but the headers can be used from regular C/C++ too. Do you think there<br>
might be issues there?<br></blockquote><div><br></div><div>The errors are DefaultError ExtWarns, so they will be suppressed by default in system headers. Even then:</div><div> * In Objective-C (and Objective-C++), the prior rule is unchanged.</div><div> * In (non-Objective) C++11 onwards, we now enforce the standard rules. (System headers should ideally be valid code, but if not, the system header exclusion will kick in. And the errors can be disabled by warning flag in user code written against old Clang.)</div><div> * In any other language mode, system headers should really not be using this functionality, since it's a non-standard language extension, and not supported by (for example) GCC. (With the same provisos as in the prior bullet.)</div><div><br></div><div>We can make the C++ side of things more permissive if necessary, but I'm hopeful that we will be able to enforce the standard rules by default in this instance.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
(See <a href="https://chromium-review.googlesource.com/c/chromium/src/+/2193673" rel="noreferrer" target="_blank">https://chromium-review.googlesource.com/c/chromium/src/+/2193673</a><br>
for the Chromium discussion.)<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div></div>