This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH][RFC] Add quotes for constexpr keyword.


On 11/15/2017 09:38 AM, Jonathan Wakely wrote:
On 15/11/17 09:30 -0700, Martin Sebor wrote:
On 11/15/2017 05:45 AM, Martin Liška wrote:
On 11/06/2017 07:29 PM, Martin Sebor wrote:
Sorry for being late with my comment.  I just spotted this minor
formatting issue.  Even though GCC isn't (yet) consistent about
it the keyword "constexpr" should be quoted in the error message
below (and, eventually, in all diagnostic messages).  Since the
patch has been committed by now this is just a reminder for us
to try to keep this in mind in the future.

Hi.

I've prepared patch for that. If it's desired, I can fix test-suite
follow-up.
Do we want to change it also for error messages like:
"call to non-constexpr function"
"constexpr call flows off the end of the function"

If GCC had support for italics for defined terms of the language
or the grammar /constexpr function/ would be italicized because
it's a defined term.  Absent that, I think I would quote them all
for consistency.

Martin

PS I checked the C++ standard to see how it used the term and
the choices it makes seem pretty arbitrary.  There are even
sentences with two instances of two word, one in fixed width
font and the other in proportional.  So I don't think we can
use the spec as an example to follow.

Did you check the latest draft? That should have been fixed.

Defined terms should only be italicized when introduced, not when
used, e.g. in [dcl.constexpr] p2 "constexpr function" and "constexpr
constructor" are italicized, but are in normal font elsewhere. When
referring specifically to the keyword `constexpr` it should be in code
font.

Grammar productions are always italicized, but "constexpr function" is
not a grammar production.

Right, /constexpr function/ is a defined term (as is /constexpr
cosntructor/ and /constexpr if/).  As you say, its defining
occurrence is italicized in the text, and the rest aren't.
In contrast, in terms like "constexpr specifier," "constexpr"
is the keyword and it's always in monospace.

The challenge in GCC as I see it is to know how to decide which
of the two it is.  The difference between constexpr the keyword
and constexpr as part of a defined term is too subtle for most
people who don't work with the standard for a living.  So we end
up with these minor inconsistencies in the diagnostics.  I think
the easiest way to achieve consistency (in diagnostics) it is to
always quote keywords.  Having italics would be a nice touch but
it would probably not improve consistency.

Martin

PS I was looking at the February 2017 draft.  The October version
looks quite a bit better.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]