r236231 - in /trunk/gcc: c/ChangeLog c/c-decl.c...

jsm28@gcc.gnu.org jsm28@gcc.gnu.org
Fri May 13 21:35:00 GMT 2016


Author: jsm28
Date: Fri May 13 21:35:39 2016
New Revision: 236231

URL: https://gcc.gnu.org/viewcvs?rev=236231&root=gcc&view=rev
Log:
Implement C11 DR#423 resolution (ignore function return type qualifiers).

The resolution of C11 DR#423, apart from doing things with the types
of expressions cast to qualified types which are only in standard
terms observable with _Generic and which agree with how GCC has
implemented _Generic all along, also specifies that qualifiers are
discarded from function return types: "derived-declarator-type-list
function returning T" becomes "derived-declarator-type-list function
returning the unqualified version of T" in the rules giving types for
function declarators.  This means that declarations of a function with
both qualified and unqualified return types are now compatible,
similar to how different declarations can vary in whether a function
argument is declared with a qualifier or unqualified type.

This patch implements this resolution.  Since the motivation for the
change was _Generic, the resolution is restricted to C11 mode; there's
no reason to consider there to be a defect in this regard in older
standard versions.  Some less-obvious issues are handled as follows:

* As usual, and as with function arguments, _Atomic is not considered
  a qualifier for this purpose; that is, function declarations must
  agree regarding whether the return type is atomic.

* By 6.9.1#2, a function definition cannot return qualified void.  But
  with this change, specifying "const void" in the declaration
  produces the type "function returning void", which is perfectly
  valid, so "const void f (void) {}" is no longer an error.

* The application to restrict is less clear.  The way I am
  interpreting it in this patch is that "unqualified version of T" is
  not valid if T is not valid, as in the case where T is a
  restrict-qualified version of a type that cannot be restrict
  qualified (non-pointer, or pointer-to-function).  But it's possible
  to argue the other way from the wording.

Bootstrapped with no regressions on x86_64-pc-linux-gnu.

gcc/c:
	* c-decl.c (grokdeclarator): For C11, discard qualifiers on
	function return type.

gcc/testsuite:
	* gcc.dg/qual-return-5.c, gcc.dg/qual-return-6.c: New tests.
	* gcc.dg/call-diag-2.c, gcc.dg/qual-return-2.c ,
	gcc.dg/qual-return-3.c, gcc.dg/qual-return-4.c: Use -std=gnu99.

Added:
    trunk/gcc/testsuite/gcc.dg/qual-return-5.c
    trunk/gcc/testsuite/gcc.dg/qual-return-6.c
Modified:
    trunk/gcc/c/ChangeLog
    trunk/gcc/c/c-decl.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gcc.dg/call-diag-2.c
    trunk/gcc/testsuite/gcc.dg/qual-return-2.c
    trunk/gcc/testsuite/gcc.dg/qual-return-3.c
    trunk/gcc/testsuite/gcc.dg/qual-return-4.c



More information about the Gcc-cvs mailing list