From: Jakub Jelinek Date: Fri, 30 Aug 2019 12:25:43 +0000 (+0200) Subject: backport: re PR c/89734 (const qualifier on return type not erased inside __typeof__) X-Git-Tag: releases/gcc-7.5.0~229 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2d51e5a7af9a1625a56c272ac1c1b602ae414978;p=thirdparty%2Fgcc.git backport: re PR c/89734 (const qualifier on return type not erased inside __typeof__) Backported from mainline 2019-03-19 Jakub Jelinek PR c/89734 * c-decl.c (grokdeclarator): Call c_build_qualified_type on function return type even if quals_used is 0. Formatting fixes. * gcc.dg/pr89734.c: New test. From-SVN: r275134 --- diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index ab2eae1ff375..e6108f1b3b3b 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,12 @@ +2019-08-30 Jakub Jelinek + + Backported from mainline + 2019-03-19 Jakub Jelinek + + PR c/89734 + * c-decl.c (grokdeclarator): Call c_build_qualified_type on function + return type even if quals_used is 0. Formatting fixes. + 2019-01-16 Joseph Myers Backport from mainline diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c index 14a3832f7bf9..8342094f3540 100644 --- a/gcc/c/c-decl.c +++ b/gcc/c/c-decl.c @@ -6361,10 +6361,12 @@ grokdeclarator (const struct c_declarator *declarator, quals_used &= TYPE_QUAL_ATOMIC; if (quals_used && VOID_TYPE_P (type) && really_funcdef) pedwarn (specs_loc, 0, - "function definition has qualified void return type"); + "function definition has qualified void " + "return type"); else warning_at (specs_loc, OPT_Wignored_qualifiers, - "type qualifiers ignored on function return type"); + "type qualifiers ignored on function " + "return type"); /* Ensure an error for restrict on invalid types; the DR#423 resolution is not entirely clear about @@ -6374,8 +6376,7 @@ grokdeclarator (const struct c_declarator *declarator, && (!POINTER_TYPE_P (type) || !C_TYPE_OBJECT_OR_INCOMPLETE_P (TREE_TYPE (type)))) error_at (loc, "invalid use of %"); - if (quals_used) - type = c_build_qualified_type (type, quals_used); + type = c_build_qualified_type (type, quals_used); } type_quals = TYPE_UNQUALIFIED; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7a134fcc4fac..1fc3ef919c14 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,6 +1,11 @@ 2019-08-30 Jakub Jelinek Backported from mainline + 2019-03-19 Jakub Jelinek + + PR c/89734 + * gcc.dg/pr89734.c: New test. + 2019-03-15 Jakub Jelinek PR debug/89704 diff --git a/gcc/testsuite/gcc.dg/pr89734.c b/gcc/testsuite/gcc.dg/pr89734.c new file mode 100644 index 000000000000..4dc27548ab28 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr89734.c @@ -0,0 +1,12 @@ +/* PR c/89734 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +typedef const int CI; +typedef _Atomic int AI; + +CI foo (void); +const int foo (void); + +AI baz (void); +_Atomic int baz (void);