(duplicate_decls): For builtins, create new function
authorRichard Stallman <rms@gnu.org>
Wed, 25 Nov 1992 17:33:21 +0000 (17:33 +0000)
committerRichard Stallman <rms@gnu.org>
Wed, 25 Nov 1992 17:33:21 +0000 (17:33 +0000)
type instead of trying to modify old one.

(c_decode_option): Decode -Wreturn-type.

From-SVN: r2794

gcc/c-decl.c

index 5f5a19181f6f0a9f97b40fa1865eadf2626ce7ac..7c7cab71d05cdc995a66ecc6a4d2c777d9b7c669 100644 (file)
@@ -1305,10 +1305,15 @@ duplicate_decls (newdecl, olddecl)
          tree newreturntype = TREE_TYPE (TREE_TYPE (newdecl));
           if (TYPE_MODE (oldreturntype) == TYPE_MODE (newreturntype))
             {
-              TREE_TYPE (TREE_TYPE (olddecl)) = newreturntype;
-              types_match = comptypes (TREE_TYPE (newdecl), TREE_TYPE (olddecl));
-             if (!types_match)
-               TREE_TYPE (TREE_TYPE (olddecl)) = oldreturntype;
+             /* Function types may be shared, so we can't just modify
+                the return type of olddecl's function type.  */
+             tree newtype
+               = build_function_type (newreturntype,
+                                      TYPE_ARG_TYPES (TREE_TYPE (olddecl)));
+             
+              types_match = comptypes (TREE_TYPE (newdecl), newtype);
+             if (types_match)
+               TREE_TYPE (olddecl) = newtype;
            }
        }
       if (!types_match)