re PR c/89734 (const qualifier on return type not erased inside __typeof__)
authorJakub Jelinek <jakub@redhat.com>
Tue, 19 Mar 2019 06:55:31 +0000 (07:55 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 19 Mar 2019 06:55:31 +0000 (07:55 +0100)
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: r269789

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

index fafc6a5ce68fa7fda061966c727de205651c8023..fd3d009f13ed206588ffc299b35d63307aa1b32a 100644 (file)
@@ -1,3 +1,9 @@
+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-03-14  Richard Biener  <rguenther@suse.de>
 
        * c-tree.h (enum c_declspec_il): New.
index d8fa10966b2890017305058e8fe76938adf578dc..e8b7ca4ae5b9ec834d1b474399df13a1258eb378 100644 (file)
@@ -6611,10 +6611,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
@@ -6624,8 +6626,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 97bfd50c5ed8723351c6fb01a1a4b9c20be3ac90..308753e3046e70c10f3a6e57517fe38833a4d9c0 100644 (file)
@@ -1,3 +1,8 @@
+2019-03-19  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c/89734
+       * gcc.dg/pr89734.c: New test.
+
 2019-03-18  Martin Sebor  <msebor@redhat.com>
 
        PR tree-optimization/89720
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);