]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR c/89734 (const qualifier on return type not erased inside __typeof__)
authorJakub Jelinek <jakub@redhat.com>
Fri, 30 Aug 2019 12:25:43 +0000 (14:25 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 30 Aug 2019 12:25:43 +0000 (14:25 +0200)
Backported from mainline
2019-03-19  Jakub Jelinek  <jakub@redhat.com>

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

gcc/c/ChangeLog
gcc/c/c-decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr89734.c [new file with mode: 0644]

index ab2eae1ff375a399fc2f426806b8f8df287738a2..e6108f1b3b3b11a353313b803fd3006ddc2fd016 100644 (file)
@@ -1,3 +1,12 @@
+2019-08-30  Jakub Jelinek  <jakub@redhat.com>
+
+       Backported from mainline
+       2019-03-19  Jakub Jelinek  <jakub@redhat.com>
+
+       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  <joseph@codesourcery.com>
 
        Backport from mainline
index 14a3832f7bf9c94bb0007a6ef533063a655d48f6..8342094f35405bb2f7d12453358e24da19b5a4f9 100644 (file)
@@ -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 %<restrict%>");
-               if (quals_used)
-                 type = c_build_qualified_type (type, quals_used);
+               type = c_build_qualified_type (type, quals_used);
              }
            type_quals = TYPE_UNQUALIFIED;
 
index 7a134fcc4fac861e2c61ed91a4f5b6ce1d0b0928..1fc3ef919c1437c882b983334e1d38919e2f026c 100644 (file)
@@ -1,6 +1,11 @@
 2019-08-30  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2019-03-19  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c/89734
+       * gcc.dg/pr89734.c: New test.
+
        2019-03-15  Jakub Jelinek  <jakub@redhat.com>
 
        PR debug/89704
diff --git a/gcc/testsuite/gcc.dg/pr89734.c b/gcc/testsuite/gcc.dg/pr89734.c
new file mode 100644 (file)
index 0000000..4dc2754
--- /dev/null
@@ -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);