diff mbox series

Add -std=c18 etc. option aliases

Message ID alpine.DEB.2.20.1711162223340.14274@digraph.polyomino.org.uk
State New
Headers show
Series Add -std=c18 etc. option aliases | expand

Commit Message

Joseph Myers Nov. 16, 2017, 10:24 p.m. UTC
ISO C17 won't go to ballot until December, meaning publication of the
standard won't be until 2018, leaving ambiguity as to whether people
will end up referring to the standard as C17, as it's currently known
and which corresponds to the __STDC_VERSION__ value, or C18 based on
the publication date.

In case people end up referring to this standard as C18, this patch
adds corresponding option aliases -std=c18, -std=iso9899:2018,
-std=gnu18 so people can use those names based on publication date if
they wish.  The "expected to be" explanations in help texts and the
manual can be removed as and when the standard is published, hopefully
before GCC 8 is out.

Bootstrapped with no regressions on x86_64-pc-linux-gnu.  Applied to 
mainline.

gcc:
2017-11-16  Joseph Myers  <joseph@codesourcery.com>

	* doc/invoke.texi (-std=c17): Refer to 2018 expected publication
	date of C17.
	(-std=c18, -std=iso9899:2018, -std=gnu18): Document option
	aliases.

gcc/c-family:
2017-11-16  Joseph Myers  <joseph@codesourcery.com>

	* c.opt (-std=c17, std=gnu17, -std=iso9899:2017): Refer to 2018
	expected publication date of C17.
	(-std=c18, -std=gnu18, -std=iso9899:2018): New option aliases.

gcc/testsuite:
2017-11-16  Joseph Myers  <joseph@codesourcery.com>

	* gcc.dg/c18-version-1.c, gcc.dg/c18-version-2.c: New tests.

Comments

Mike Stump Nov. 16, 2017, 11:15 p.m. UTC | #1
On Nov 16, 2017, at 2:24 PM, Joseph Myers <joseph@codesourcery.com> wrote:
> 
> ISO C17 won't go to ballot until December, meaning publication of the
> standard won't be until 2018, leaving ambiguity as to whether people
> will end up referring to the standard as C17, as it's currently known
> and which corresponds to the __STDC_VERSION__ value, or C18 based on
> the publication date.

C++98 was similar.  The last draft was in 97, but, the actual ISO standard was 98.   I think the ANSI version was done in 97.  The name 97 is never, ever used, and c++98 names it pretty well.  cplusplus has a 97 date on it.  If there was no major release with c17, I would ditch the c17 spelling and just change it to c18 now.  :-)  I know, kinda sucks, but, until published, it just doesn't exist.  This is why we use 0x, and other names that we can safely deprecate for c++.  Concerning iso9899:2017, naming an actual document that doesn't exist, strikes me as wrong.  I've advise against it.
Joseph Myers Nov. 16, 2017, 11:34 p.m. UTC | #2
On Thu, 16 Nov 2017, Mike Stump wrote:

> date on it.  If there was no major release with c17, I would ditch the 
> c17 spelling and just change it to c18 now.  :-)  I know, kinda sucks, 

There is no evidence yet of anyone using the C18 name.  So far, it's 
consistently being referred to as C17 in development, even after the 
timescale for the ballot / publication has become clear.  But given the 
possibility that some people might think of it as C18 based on the 
publication date, being prepared with aliases seems useful.

The name -std=iso9899:2017 follows the precedent of -std=iso9899:199409 in 
being based on the __STDC_VERSION__ value rather than the publication 
date.
Jakub Jelinek Nov. 17, 2017, 7:39 a.m. UTC | #3
On Thu, Nov 16, 2017 at 11:34:07PM +0000, Joseph Myers wrote:
> On Thu, 16 Nov 2017, Mike Stump wrote:
> 
> > date on it.  If there was no major release with c17, I would ditch the 
> > c17 spelling and just change it to c18 now.  :-)  I know, kinda sucks, 
> 
> There is no evidence yet of anyone using the C18 name.  So far, it's 
> consistently being referred to as C17 in development, even after the 
> timescale for the ballot / publication has become clear.  But given the 
> possibility that some people might think of it as C18 based on the 
> publication date, being prepared with aliases seems useful.
> 
> The name -std=iso9899:2017 follows the precedent of -std=iso9899:199409 in 
> being based on the __STDC_VERSION__ value rather than the publication 
> date.

Note AFAIK C++14 has been published in January 2015 too, initially
14882:2015 and then changed to 14882:2014.

	Jakub
diff mbox series

Patch

Index: gcc/c-family/c.opt
===================================================================
--- gcc/c-family/c.opt	(revision 254837)
+++ gcc/c-family/c.opt	(working copy)
@@ -1950,8 +1950,12 @@ 
 
 std=c17
 C ObjC
-Conform to the ISO 2017 C standard.
+Conform to the ISO 2017 C standard (expected to be published in 2018).
 
+std=c18
+C ObjC Alias(std=c17)
+Conform to the ISO 2017 C standard (expected to be published in 2018).
+
 std=c89
 C ObjC Alias(std=c90)
 Conform to the ISO 1990 C standard.
@@ -2016,8 +2020,12 @@ 
 
 std=gnu17
 C ObjC
-Conform to the ISO 2017 C standard with GNU extensions.
+Conform to the ISO 2017 C standard (expected to be published in 2018) with GNU extensions.
 
+std=gnu18
+C ObjC Alias(std=gnu17)
+Conform to the ISO 2017 C standard (expected to be published in 2018) with GNU extensions.
+
 std=gnu89
 C ObjC Alias(std=gnu90)
 Conform to the ISO 1990 C standard with GNU extensions.
@@ -2056,8 +2064,12 @@ 
 
 std=iso9899:2017
 C ObjC Alias(std=c17)
-Conform to the ISO 2017 C standard.
+Conform to the ISO 2017 C standard (expected to be published in 2018).
 
+std=iso9899:2018
+C ObjC Alias(std=c17)
+Conform to the ISO 2017 C standard (expected to be published in 2018).
+
 traditional
 Driver
 
Index: gcc/doc/invoke.texi
===================================================================
--- gcc/doc/invoke.texi	(revision 254837)
+++ gcc/doc/invoke.texi	(working copy)
@@ -1832,8 +1832,11 @@ 
 interfaces) and L (Analyzability).  The name @samp{c1x} is deprecated.
 
 @item c17
+@itemx c18
 @itemx iso9899:2017
-ISO C17, the 2017 revision of the ISO C standard.  This standard is
+@itemx iso9899:2018
+ISO C17, the 2017 revision of the ISO C standard (expected to be
+published in 2018).  This standard is
 same as C11 except for corrections of defects (all of which are also
 applied with @option{-std=c11}) and a new value of
 @code{__STDC_VERSION__}, and so is supported to the same extent as C11.
@@ -1852,6 +1855,7 @@ 
 The name @samp{gnu1x} is deprecated.
 
 @item gnu17
+@itemx gnu18
 GNU dialect of ISO C17.  This is the default for C code.
 
 @item c++98
Index: gcc/testsuite/gcc.dg/c18-version-1.c
===================================================================
--- gcc/testsuite/gcc.dg/c18-version-1.c	(nonexistent)
+++ gcc/testsuite/gcc.dg/c18-version-1.c	(working copy)
@@ -0,0 +1,9 @@ 
+/* Test __STDC_VERSION__ for C17.  Test -std=c18.  */
+/* { dg-do compile } */
+/* { dg-options "-std=c18 -pedantic-errors" } */
+
+#if __STDC_VERSION__ == 201710L
+int i;
+#else
+#error "Bad __STDC_VERSION__."
+#endif
Index: gcc/testsuite/gcc.dg/c18-version-2.c
===================================================================
--- gcc/testsuite/gcc.dg/c18-version-2.c	(nonexistent)
+++ gcc/testsuite/gcc.dg/c18-version-2.c	(working copy)
@@ -0,0 +1,9 @@ 
+/* Test __STDC_VERSION__ for C17.  Test -std=iso9899:2018.  */
+/* { dg-do compile } */
+/* { dg-options "-std=iso9899:2018 -pedantic-errors" } */
+
+#if __STDC_VERSION__ == 201710L
+int i;
+#else
+#error "Bad __STDC_VERSION__."
+#endif