re PR c/20631 (Support -std=c90 as alias for -std=c89)

2010-02-26  Manuel López-Ibáñez  <manu@gcc.gnu.org>

	PR c/20631
	* doc/cpp.texi: Use c90 instead of c89 and gnu90 instead of gnu89.
	* doc/standards.texi: Likewise.
	* doc/extend.texi: Likewise.
	* doc/trouble.texi: Likewise.
	* doc/cppopts.texi: Likewise. 
	* doc/install.texi: Likewise.
	* c.opt (std=c90,std=gnu90): New options.
	* c-opts.c (c_common_handle_option): Handle them.
testsuite/
	* gcc.dg/cpp/c90-pedantic.c: New.
	* gcc.dg/cpp/c90.c: New.
	* gcc.dg/gnu90-const-expr-1.c: New.
	* gcc.dg/Woverlength-strings-pedantic-c90.c: New.

From-SVN: r157096
This commit is contained in:
Manuel López-Ibáñez 2010-02-26 17:09:29 +00:00
parent 0b901e4cdc
commit 7e1542b921
15 changed files with 176 additions and 46 deletions

View File

@ -1,3 +1,15 @@
2010-02-26 Manuel López-Ibáñez <manu@gcc.gnu.org>
PR c/20631
* doc/cpp.texi: Use c90 instead of c89 and gnu90 instead of gnu89.
* doc/standards.texi: Likewise.
* doc/extend.texi: Likewise.
* doc/trouble.texi: Likewise.
* doc/cppopts.texi: Likewise.
* doc/install.texi: Likewise.
* c.opt (std=c90,std=gnu90): New options.
* c-opts.c (c_common_handle_option): Handle them.
2010-02-26 Manuel López-Ibáñez <manu@gcc.gnu.org>
PR c/24577

View File

@ -952,6 +952,7 @@ c_common_handle_option (size_t scode, const char *arg, int value)
break;
case OPT_std_c89:
case OPT_std_c90:
case OPT_std_iso9899_1990:
case OPT_std_iso9899_199409:
if (!preprocessing_asm_p)
@ -959,6 +960,7 @@ c_common_handle_option (size_t scode, const char *arg, int value)
break;
case OPT_std_gnu89:
case OPT_std_gnu90:
if (!preprocessing_asm_p)
set_std_c89 (false /* c94 */, false /* ISO */);
break;

View File

@ -965,6 +965,10 @@ std=c89
C ObjC
Conform to the ISO 1990 C standard
std=c90
C ObjC
Conform to the ISO 1990 C standard
std=c99
C ObjC
Conform to the ISO 1999 C standard
@ -988,6 +992,10 @@ std=gnu89
C ObjC
Conform to the ISO 1990 C standard with GNU extensions
std=gnu90
C ObjC
Conform to the ISO 1990 C standard with GNU extensions
std=gnu99
C ObjC
Conform to the ISO 1999 C standard with GNU extensions

View File

@ -215,7 +215,7 @@ Standard C@. In its default mode, the GNU C preprocessor does not do a
few things required by the standard. These are features which are
rarely, if ever, used, and may cause surprising changes to the meaning
of a program which does not expect them. To get strict ISO Standard C,
you should use the @option{-std=c89} or @option{-std=c99} options, depending
you should use the @option{-std=c90} or @option{-std=c99} options, depending
on which version of the standard you want. To get all the mandatory
diagnostics, you must also use @option{-pedantic}. @xref{Invocation}.
@ -2064,7 +2064,7 @@ are defined. If they are defined, their value is 1.
@item __GNUC_GNU_INLINE__
GCC defines this macro if functions declared @code{inline} will be
handled in GCC's traditional gnu89 mode. Object files will contain
handled in GCC's traditional gnu90 mode. Object files will contain
externally visible definitions of all functions declared @code{inline}
without @code{extern} or @code{static}. They will not contain any
definitions of any functions declared @code{extern inline}.
@ -2077,10 +2077,10 @@ inline}. They will not contain definitions of any functions declared
@code{inline} without @code{extern}.
If this macro is defined, GCC supports the @code{gnu_inline} function
attribute as a way to always get the gnu89 behavior. Support for
attribute as a way to always get the gnu90 behavior. Support for
this and @code{__GNUC_GNU_INLINE__} was added in GCC 4.1.3. If
neither macro is defined, an older version of GCC is being used:
@code{inline} functions will be compiled in gnu89 mode, and the
@code{inline} functions will be compiled in gnu90 mode, and the
@code{gnu_inline} function attribute will not be recognized.
@item __CHAR_UNSIGNED__

View File

@ -374,12 +374,13 @@ knows about C and C++ standards; others may be added in the future.
@var{standard}
may be one of:
@table @code
@item iso9899:1990
@item c90
@itemx c89
The ISO C standard from 1990. @samp{c89} is the customary shorthand for
@itemx iso9899:1990
The ISO C standard from 1990. @samp{c90} is the customary shorthand for
this version of the standard.
The @option{-ansi} option is equivalent to @option{-std=c89}.
The @option{-ansi} option is equivalent to @option{-std=c90}.
@item iso9899:199409
The 1990 C standard, as amended in 1994.
@ -391,7 +392,8 @@ The 1990 C standard, as amended in 1994.
The revised ISO C standard, published in December 1999. Before
publication, this was known as C9X@.
@item gnu89
@item gnu90
@itemx gnu89
The 1990 C standard plus GNU extensions. This is the default.
@item gnu99

View File

@ -21,8 +21,8 @@ These extensions are available in C and Objective-C@. Most of them are
also available in C++. @xref{C++ Extensions,,Extensions to the
C++ Language}, for extensions that apply @emph{only} to C++.
Some features that are in ISO C99 but not C89 or C++ are also, as
extensions, accepted by GCC in C89 mode and in C++.
Some features that are in ISO C99 but not C90 or C++ are also, as
extensions, accepted by GCC in C90 mode and in C++.
@menu
* Statement Exprs:: Putting statements and declarations inside expressions.
@ -813,7 +813,7 @@ effects of recomputing it.
@cindex @code{ULL} integer suffix
ISO C99 supports data types for integers that are at least 64 bits wide,
and as an extension GCC supports them in C89 mode and in C++.
and as an extension GCC supports them in C90 mode and in C++.
Simply write @code{long long int} for a signed integer, or
@code{unsigned long long int} for an unsigned integer. To make an
integer constant of type @code{long long int}, add the suffix @samp{LL}
@ -843,7 +843,7 @@ Likewise, if the function expects @code{long long int} and you pass
@cindex @code{__complex__} keyword
ISO C99 supports complex floating data types, and as an extension GCC
supports them in C89 mode and in C++, and supports complex integer data
supports them in C90 mode and in C++, and supports complex integer data
types which are not part of ISO C99. You can declare complex types
using the keyword @code{_Complex}. As an extension, the older GNU
keyword @code{__complex__} is also supported.
@ -1032,7 +1032,7 @@ are supported by the DWARF2 debug information format.
ISO C99 supports floating-point numbers written not only in the usual
decimal notation, such as @code{1.55e1}, but also numbers such as
@code{0x1.fp3} written in hexadecimal format. As a GNU extension, GCC
supports this in C89 mode (except in some cases when strictly
supports this in C90 mode (except in some cases when strictly
conforming) and in C++. In that format the
@samp{0x} hex introducer and the @samp{p} or @samp{P} exponent field are
mandatory. The exponent is a decimal number that indicates the power of
@ -1345,7 +1345,7 @@ member of type @code{char}.
@cindex VLAs
Variable-length automatic arrays are allowed in ISO C99, and as an
extension GCC accepts them in C89 mode and in C++. (However, GCC's
extension GCC accepts them in C90 mode and in C++. (However, GCC's
implementation of variable-length arrays does not yet conform in detail
to the ISO C99 standard.) These arrays are
declared like any other automatic arrays, but with a length that is not
@ -1511,9 +1511,9 @@ In ISO C99, arrays that are not lvalues still decay to pointers, and
may be subscripted, although they may not be modified or used after
the next sequence point and the unary @samp{&} operator may not be
applied to them. As an extension, GCC allows such arrays to be
subscripted in C89 mode, though otherwise they do not decay to
subscripted in C90 mode, though otherwise they do not decay to
pointers outside C99 mode. For example,
this is valid in GNU C though not valid in C89:
this is valid in GNU C though not valid in C90:
@smallexample
@group
@ -1576,7 +1576,7 @@ ISO C99 supports compound literals. A compound literal looks like
a cast containing an initializer. Its value is an object of the
type specified in the cast, containing the elements specified in
the initializer; it is an lvalue. As an extension, GCC supports
compound literals in C89 mode and in C++.
compound literals in C90 mode and in C++.
Usually, the specified type is a structure. Assume that
@code{struct foo} and @code{structure} are declared as shown:
@ -1646,13 +1646,13 @@ static int z[] = @{1, 0, 0@};
@cindex case labels in initializers
@cindex designated initializers
Standard C89 requires the elements of an initializer to appear in a fixed
Standard C90 requires the elements of an initializer to appear in a fixed
order, the same as the order of the elements in the array or structure
being initialized.
In ISO C99 you can give the elements in any order, specifying the array
indices or structure field names they apply to, and GNU C allows this as
an extension in C89 mode as well. This extension is not
an extension in C90 mode as well. This extension is not
implemented in GNU C++.
To specify an array index, write
@ -1869,7 +1869,7 @@ hack ((union foo) x);
ISO C99 and ISO C++ allow declarations and code to be freely mixed
within compound statements. As an extension, GCC also allows this in
C89 mode. For example, you could do:
C90 mode. For example, you could do:
@smallexample
int i;
@ -2006,7 +2006,7 @@ if no optimization level was specified.
@cindex @code{gnu_inline} function attribute
This attribute should be used with a function which is also declared
with the @code{inline} keyword. It directs GCC to treat the function
as if it were defined in gnu89 mode even when compiling in C99 or
as if it were defined in gnu90 mode even when compiling in C99 or
gnu99 mode.
If the function is declared @code{extern}, then this definition of the
@ -3837,7 +3837,7 @@ continue until the end of the line. Many other C implementations allow
such comments, and they are included in the 1999 C standard. However,
C++ style comments are not recognized if you specify an @option{-std}
option specifying a version of ISO C before C99, or @option{-ansi}
(equivalent to @option{-std=c89}).
(equivalent to @option{-std=c90}).
@node Dollar Signs
@section Dollar Signs in Identifier Names
@ -4938,7 +4938,7 @@ inc (int *a)
@}
@end smallexample
If you are writing a header file to be included in ISO C89 programs, write
If you are writing a header file to be included in ISO C90 programs, write
@code{__inline__} instead of @code{inline}. @xref{Alternate Keywords}.
The three types of inlining behave similarly in two important cases:
@ -5001,7 +5001,7 @@ the @samp{always_inline} attribute for the function, like this:
inline void foo (const char) __attribute__((always_inline));
@end smallexample
The remainder of this section is specific to GNU C89 inlining.
The remainder of this section is specific to GNU C90 inlining.
@cindex non-static inline function
When an inline function is not @code{static}, then the compiler must assume
@ -6844,7 +6844,7 @@ be emitted.
@opindex ansi
@opindex std
Outside strict ISO C mode (@option{-ansi}, @option{-std=c89} or
Outside strict ISO C mode (@option{-ansi}, @option{-std=c90} or
@option{-std=c99}), the functions
@code{_exit}, @code{alloca}, @code{bcmp}, @code{bzero},
@code{dcgettext}, @code{dgettext}, @code{dremf}, @code{dreml},
@ -6867,7 +6867,7 @@ Outside strict ISO C mode (@option{-ansi}, @option{-std=c89} or
@code{yn}
may be handled as built-in functions.
All these functions have corresponding versions
prefixed with @code{__builtin_}, which may be used even in strict C89
prefixed with @code{__builtin_}, which may be used even in strict C90
mode.
The ISO C99 functions
@ -6911,7 +6911,7 @@ The ISO C99 functions
@code{tgamma}, @code{truncf}, @code{truncl}, @code{trunc},
@code{vfscanf}, @code{vscanf}, @code{vsnprintf} and @code{vsscanf}
are handled as built-in functions
except in strict ISO C90 mode (@option{-ansi} or @option{-std=c89}).
except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
There are also built-in versions of the ISO C99 functions
@code{acosf}, @code{acosl}, @code{asinf}, @code{asinl}, @code{atan2f},
@ -6933,7 +6933,7 @@ The ISO C94 functions
@code{iswspace}, @code{iswupper}, @code{iswxdigit}, @code{towlower} and
@code{towupper}
are handled as built-in functions
except in strict ISO C90 mode (@option{-ansi} or @option{-std=c89}).
except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
The ISO C90 functions
@code{abort}, @code{abs}, @code{acos}, @code{asin}, @code{atan2},

View File

@ -4126,11 +4126,11 @@ release.
Sun bug 4296832 turns up when compiling X11 headers with GCC 2.95 or
newer: @command{g++} will complain that types are missing. These headers
assume that omitting the type means @code{int}; this assumption worked for
C89 but is wrong for C++, and is now wrong for C99 also.
C90 but is wrong for C++, and is now wrong for C99 also.
@command{g++} accepts such (invalid) constructs with the option
@option{-fpermissive}; it will assume that any missing type is @code{int}
(as defined by C89).
(as defined by C90).
There are patches for Solaris 7 (108376-21 or newer for SPARC,
108377-20 for Intel), and Solaris 8 (108652-24 or newer for SPARC,

View File

@ -1425,7 +1425,7 @@ accepts:
@cindex ISO support
@item -ansi
@opindex ansi
In C mode, this is equivalent to @samp{-std=c89}. In C++ mode, it is
In C mode, this is equivalent to @samp{-std=c90}. In C++ mode, it is
equivalent to @samp{-std=c++98}.
This turns off certain features of GCC that are incompatible with ISO
@ -1467,12 +1467,12 @@ Determine the language standard. @xref{Standards,,Language Standards
Supported by GCC}, for details of these standard versions. This option
is currently only supported when compiling C or C++.
The compiler can accept several base standards, such as @samp{c89} or
The compiler can accept several base standards, such as @samp{c90} or
@samp{c++98}, and GNU dialects of those standards, such as
@samp{gnu89} or @samp{gnu++98}. By specifying a base standard, the
@samp{gnu90} or @samp{gnu++98}. By specifying a base standard, the
compiler will accept all programs following that standard and those
using GNU extensions that do not contradict it. For example,
@samp{-std=c89} turns off certain features of GCC that are
@samp{-std=c90} turns off certain features of GCC that are
incompatible with ISO C90, such as the @code{asm} and @code{typeof}
keywords, but not other GNU extensions that do not have a meaning in
ISO C90, such as omitting the middle term of a @code{?:}
@ -1482,13 +1482,14 @@ those features change the meaning of the base standard and some
strict-conforming programs may be rejected. The particular standard
is used by @option{-pedantic} to identify which features are GNU
extensions given that version of the standard. For example
@samp{-std=gnu89 -pedantic} would warn about C++ style @samp{//}
@samp{-std=gnu90 -pedantic} would warn about C++ style @samp{//}
comments, while @samp{-std=gnu99 -pedantic} would not.
A value for this option must be provided; possible values are
@table @samp
@item c89
@item c90
@itemx c89
@itemx iso9899:1990
Support all ISO C90 programs (certain GNU extensions that conflict
with ISO C90 are disabled). Same as @option{-ansi} for C code.
@ -1504,7 +1505,8 @@ ISO C99. Note that this standard is not yet fully supported; see
@w{@uref{http://gcc.gnu.org/c99status.html}} for more information. The
names @samp{c9x} and @samp{iso9899:199x} are deprecated.
@item gnu89
@item gnu90
@itemx gnu89
GNU dialect of ISO C90 (including some C99 features). This
is the default for C code.
@ -1547,7 +1549,8 @@ C99 mode. Using this option is roughly equivalent to adding the
The option @option{-fno-gnu89-inline} explicitly tells GCC to use the
C99 semantics for @code{inline} when in C99 or gnu99 mode (i.e., it
specifies the default behavior). This option was first supported in
GCC 4.3. This option is not supported in C89 or gnu89 mode.
GCC 4.3. This option is not supported in @option{-std=c90} or
@option{-std=gnu90} mode.
The preprocessor macros @code{__GNUC_GNU_INLINE__} and
@code{__GNUC_STDC_INLINE__} may be used to check which semantics are
@ -2842,7 +2845,7 @@ be quite different from @option{-pedantic}. We don't have plans to
support such a feature in the near future.
Where the standard specified with @option{-std} represents a GNU
extended dialect of C, such as @samp{gnu89} or @samp{gnu99}, there is a
extended dialect of C, such as @samp{gnu90} or @samp{gnu99}, there is a
corresponding @dfn{base standard}, the version of ISO C on which the GNU
extended dialect is based. Warnings from @option{-pedantic} are given
where they are required by the base standard. (It would not make sense
@ -4342,7 +4345,7 @@ standard's minimum limit, but very portable programs should avoid
using longer strings.
The limit applies @emph{after} string constant concatenation, and does
not count the trailing NUL@. In C89, the limit was 509 characters; in
not count the trailing NUL@. In C90, the limit was 509 characters; in
C99, it was raised to 4095. C++98 does not specify a normative
minimum maximum, so we do not diagnose overlength strings in C++@.
@ -5955,7 +5958,7 @@ release to an another.
In C, emit @code{static} functions that are declared @code{inline}
into the object file, even if the function has been inlined into all
of its callers. This switch does not affect functions using the
@code{extern inline} extension in GNU C89@. In C++, emit any and all
@code{extern inline} extension in GNU C90@. In C++, emit any and all
inline functions into the object file.
@item -fkeep-static-consts

View File

@ -63,7 +63,7 @@ This standard, in both its forms, is commonly known as @dfn{C89}, or
occasionally as @dfn{C90}, from the dates of ratification. The ANSI
standard, but not the ISO standard, also came with a Rationale
document. To select this standard in GCC, use one of the options
@option{-ansi}, @option{-std=c89} or @option{-std=iso9899:1990}; to obtain
@option{-ansi}, @option{-std=c90} or @option{-std=iso9899:1990}; to obtain
all the diagnostics required by the standard, you should also specify
@option{-pedantic} (or @option{-pedantic-errors} if you want them to be
errors rather than warnings). @xref{C Dialect Options,,Options
@ -99,12 +99,12 @@ Extensions,,Extensions to the C Language Family}. Use of the
@option{-std} options listed above will disable these extensions where
they conflict with the C standard version selected. You may also
select an extended version of the C language explicitly with
@option{-std=gnu89} (for C89 with GNU extensions) or @option{-std=gnu99}
@option{-std=gnu90} (for C90 with GNU extensions) or @option{-std=gnu99}
(for C99 with GNU extensions). The default, if no C language dialect
options are given, is @option{-std=gnu89}; this will change to
options are given, is @option{-std=gnu90}; this will change to
@option{-std=gnu99} in some future release when the C99 support is
complete. Some features that are part of the C99 standard are
accepted as extensions in C89 mode.
accepted as extensions in C90 mode.
The ISO C standard defines (in clause 4) two classes of conforming
implementation. A @dfn{conforming hosted implementation} supports the

View File

@ -467,7 +467,7 @@ requires that this be treated as erroneous.
A @dfn{preprocessing token} is a @dfn{preprocessing number} if it
begins with a digit and is followed by letters, underscores, digits,
periods and @samp{e+}, @samp{e-}, @samp{E+}, @samp{E-}, @samp{p+},
@samp{p-}, @samp{P+}, or @samp{P-} character sequences. (In strict C89
@samp{p-}, @samp{P+}, or @samp{P-} character sequences. (In strict C90
mode, the sequences @samp{p+}, @samp{p-}, @samp{P+} and @samp{P-} cannot
appear in preprocessing numbers.)

View File

@ -1,3 +1,11 @@
2010-02-26 Manuel López-Ibáñez <manu@gcc.gnu.org>
PR c/20631
* gcc.dg/cpp/c90-pedantic.c: New.
* gcc.dg/cpp/c90.c: New.
* gcc.dg/gnu90-const-expr-1.c: New.
* gcc.dg/Woverlength-strings-pedantic-c90.c: New.
2010-02-26 Richard Guenther <rguenther@suse.de>
PR tree-optimization/43186

View File

@ -0,0 +1,19 @@
/* -Woverlength-strings complains about string constants which are too long
for the C standard's "minimum maximum" limits. It is off by default,
but implied by -pedantic. */
/* { dg-options "-std=c90 -pedantic" } */
#define TEN "xxxxxxxxxx"
#define HUN TEN TEN TEN TEN TEN TEN TEN TEN TEN TEN
#define THO HUN HUN HUN HUN HUN HUN HUN HUN HUN HUN
/* C89's minimum-maximum is 509. */
const char x510[] = HUN HUN HUN HUN HUN TEN; /* { dg-warning "greater than" } */
/* C99's minimum-maximum is 4095. */
const char x4096[] =
THO THO THO THO /* 4000 */
TEN TEN TEN TEN TEN /* 4050 */
TEN TEN TEN TEN /* 4090 */
"123456"; /* { dg-warning "greater than" } */

View File

@ -0,0 +1,10 @@
/* Copyright (C) 2000 Free Software Foundation, Inc. */
/* { dg-do preprocess } */
/* { dg-options "-std=c90 -pedantic" } */
/* This file is for testing the preprocessor in -std=c90 -pedantic mode.
Neil Booth, 2 Dec 2000. */
#if 1LL /* { dg-warning "long long" } */
#endif

View File

@ -0,0 +1,10 @@
/* Copyright (C) 2000 Free Software Foundation, Inc. */
/* { dg-do preprocess } */
/* { dg-options "-std=c90" } */
/* This file is for testing the preprocessor in -std=c90 mode.
Neil Booth, 2 Dec 2000. */
#if 1LL
#endif

View File

@ -0,0 +1,56 @@
/* Test for constant expressions: GNU extensions. */
/* Origin: Joseph Myers <joseph@codesourcery.com> */
/* { dg-do compile } */
/* { dg-options "-std=gnu90 -pedantic-errors" } */
int n;
void
f (void)
{
int i = 0;
int a[n]; /* { dg-error "ISO C90 forbids variable length array" } */
enum e1 {
/* Integer constant expressions may not contain statement
expressions (not a permitted operand). */
E1 = (1 ? 0 : ({ 0; })), /* { dg-error "constant expression" } */
/* { dg-error "ISO C forbids braced-groups" "ISO" { target *-*-* } 16 } */
/* Real and imaginary parts act like other arithmetic
operators. */
E2 = __real__ (1 ? 0 : i++), /* { dg-error "constant expression" } */
E3 = __real__ 0,
E4 = __imag__ (1 ? 0 : i++), /* { dg-error "constant" } */
E5 = __imag__ 0,
/* __alignof__ always constant. */
E6 = __alignof__ (int[n]), /* { dg-error "ISO C90 forbids variable length array" } */
E7 = __alignof__ (a),
/* __extension__ ignored for constant expression purposes. */
E8 = __extension__ (1 ? 0 : i++), /* { dg-error "constant expression" } */
E9 = __extension__ 0,
/* Conditional expressions with omitted arguments act like the
standard type. */
E10 = (1 ? : i++), /* { dg-error "constant expression" } */
/* { dg-error "ISO C forbids omitting" "ISO" { target *-*-* } 32 } */
E11 = (1 ? : 0) /* { dg-error "ISO C forbids omitting" } */
};
enum e2 {
/* Complex integer constants may be cast directly to integer
types, but not after further arithmetic on them. */
F1 = (int) (_Complex int) 2i, /* { dg-error "constant expression" } */
/* { dg-error "complex" "complex" { target *-*-* } 39 } */
/* { dg-error "imaginary" "imaginary" { target *-*-* } 39 } */
F2 = (int) +2i, /* { dg-error "constant expression" } */
/* { dg-error "imaginary" "ISO" { target *-*-* } 42 } */
F3 = (int) (1 + 2i), /* { dg-error "constant expression" } */
/* { dg-error "imaginary" "ISO" { target *-*-* } 44 } */
F4 = (int) 2i /* { dg-error "imaginary" } */
};
static double dr = __real__ (1.0 + 2.0i);
/* { dg-error "imaginary" "ISO" { target *-*-* } 48 } */
static double di = __imag__ (1.0 + 2.0i);
/* { dg-error "imaginary" "ISO" { target *-*-* } 50 } */
/* Statement expressions allowed in unevaluated subexpressions in
initializers in gnu99 but not gnu89. */
static int j = (1 ? 0 : ({ 0; })); /* { dg-error "constant expression" } */
/* { dg-error "braced" "ISO" { target *-*-* } 54 } */
}