If a function declaration has a late-specified return type the usual checks on return types are bypassed: using Qi = int const volatile; Qi q1(); // warning: type qualifiers ignored on function return type auto q2() -> Qi; // no warning using Fi = int(); Fi f1(); // error: 'f1' declared as function returning a function auto f2() -> Fi; // error: function return type cannot be function using Ai = int[5]; Ai a1(); // error: 'a1' declared as function returning an array auto a2() -> Ai; // no error Qualifiers: previously filed as bug 38797 RESOLVED INVALID; I don't entirely agree with the resolution but am willing to let it stand. Function: shows an inconsistent and less informative error, issuing later from gcc/tree.c build_function_type(). Array: the function returning a (prvalue) array is allowed to be declared and can even be defined, called and the result subscripted, though not at -Werror=pedantic: http://stackoverflow.com/q/29628571/567292 I think it should be possible to move at least the function and array return checks to after late-specified return type evaluation.
Credit to FISOCPP (http://stackoverflow.com/q/29628571/567292) for finding this bug.
Mine.
Author: paolo Date: Mon Jul 3 18:10:52 2017 New Revision: 249935 URL: https://gcc.gnu.org/viewcvs?rev=249935&root=gcc&view=rev Log: /cp 2017-07-03 Paolo Carlini <paolo.carlini@oracle.com> PR c++/65775 * decl.c (grokdeclarator): Move checks on function return type after the splice_late_return_type call; if declspecs->locations[ds_type_spec] is UNKNOWN_LOCATION fall back to input_location. /testsuite 2017-07-03 Paolo Carlini <paolo.carlini@oracle.com> PR c++/65775 * g++.dg/cpp0x/trailing14.C: New. Added: trunk/gcc/testsuite/g++.dg/cpp0x/trailing14.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/decl.c trunk/gcc/testsuite/ChangeLog
Fixed.
*** Bug 38797 has been marked as a duplicate of this bug. ***
Author: redi Date: Thu Apr 19 15:29:03 2018 New Revision: 259499 URL: https://gcc.gnu.org/viewcvs?rev=259499&root=gcc&view=rev Log: PR c++/85464 - missing location for -Wignored-qualifiers diagnostic The fix for PR c++/69733 caused a regression for conversion operators with redundant cv-qualifiers, changing an incorrect location to an unknown location. This restores it to the incorrect location (as was already done on trunk by the fix for PR c++/65775). gcc/cp: PR c++/85464 - missing location for -Wignored-qualifiers diagnostic * decl.c (grokdeclarator): If declspecs->locations[ds_type_spec] is UNKNOWN_LOCATION fall back to input_location. gcc/testsuite: PR c++/85464 - missing location for -Wignored-qualifiers diagnostic * g++.dg/diagnostic/pr85464.C: New. Added: branches/gcc-7-branch/gcc/testsuite/g++.dg/diagnostic/pr85464.C Modified: branches/gcc-7-branch/gcc/cp/ChangeLog branches/gcc-7-branch/gcc/cp/decl.c branches/gcc-7-branch/gcc/testsuite/ChangeLog