OSDN Git Service

PR c/5503:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 14 Feb 2002 10:22:53 +0000 (10:22 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 14 Feb 2002 10:22:53 +0000 (10:22 +0000)
* c-decl.c (duplicate_decls): If builtin type has TYPE_ARG_TYPES NULL,
use arguments from newtype.

* gcc.dg/noncompile/20020213-1.c: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@49763 138bc75d-0d04-0410-961f-82ee72b054a4

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

index 304948b..a6c7601 100644 (file)
@@ -1,3 +1,9 @@
+2002-02-14  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c/5503:
+       * c-decl.c (duplicate_decls): If builtin type has TYPE_ARG_TYPES NULL,
+       use arguments from newtype.
+
 2002-02-13  Eric Christopher  <echristo@redhat.com>
 
        * config/mips/mips.c (override_options): Add check for march/mipsX
@@ -21,7 +27,7 @@
         * config/rs6000/rs6000.c (rs6000_legitimize_reload_address): Do
         not push_reload for altivec modes.
 
-2002-02-13     Joel Sherrill <joel@OARcorp.com>
+2002-02-13  Joel Sherrill  <joel@OARcorp.com>
 
        * config.gcc (a29k-*-rtems), config/a29k/rtems.h: General cleanup across
        all RTEMS targets including removal of #includes from config/*/rtems*.h
index 746fa47..ea7942c 100644 (file)
@@ -1548,6 +1548,22 @@ duplicate_decls (newdecl, olddecl, different_binding_level)
          if (! different_binding_level)
            TREE_TYPE (olddecl) = oldtype;
        }
+      else if (TYPE_ARG_TYPES (oldtype) == NULL
+              && TYPE_ARG_TYPES (newtype) != NULL)
+       {
+         /* For bcmp, bzero, fputs the builtin type has arguments not
+            specified.  Use the ones from the prototype so that type checking
+            is done for them.  */
+         tree trytype
+           = build_function_type (TREE_TYPE (oldtype),
+                                  TYPE_ARG_TYPES (newtype));
+         trytype = build_type_attribute_variant (trytype,
+                                                 TYPE_ATTRIBUTES (oldtype));
+
+         oldtype = trytype;
+         if (! different_binding_level)
+           TREE_TYPE (olddecl) = oldtype;
+       }
       if (!types_match)
        {
          /* If types don't match for a built-in, throw away the built-in.  */
index 0ae7fc4..b139854 100644 (file)
@@ -1,3 +1,7 @@
+2002-02-14  Jakub Jelinek  <jakub@redhat.com>
+
+       * gcc.dg/noncompile/20020213-1.c: New test.
+
 2002-02-13  Jakub Jelinek  <jakub@redhat.com>
 
        * g++.dg/other/debug3.C: New test.
diff --git a/gcc/testsuite/gcc.dg/noncompile/20020213-1.c b/gcc/testsuite/gcc.dg/noncompile/20020213-1.c
new file mode 100644 (file)
index 0000000..77798b5
--- /dev/null
@@ -0,0 +1,31 @@
+/* PR c/5503
+   Test whether argument checking is done for fputs, bzero and bcmp.  */
+typedef struct { int i; } FILE;
+typedef __SIZE_TYPE__ size_t;
+int fputs (const char *, FILE *);
+void bzero (void *, size_t);
+int bcmp (const void *, const void *, size_t);
+
+char buf[32];
+FILE *f;
+
+int main ()
+{
+  fputs ("foo");               /* { dg-error "too few" } */
+  fputs ("foo", "bar", "baz"); /* { dg-error "too many" } */
+  fputs (21, 43);
+  bzero (buf);                 /* { dg-error "too few" } */
+  bzero (21);                  /* { dg-error "too few" } */
+  bcmp (buf, buf + 16);                /* { dg-error "too few" } */
+  bcmp (21);                   /* { dg-error "too few" } */
+  fputs ("foo", f);
+  bzero (buf, 32);
+  bcmp (buf, buf + 16, 16);
+  return 0;
+}
+
+/* { dg-warning "passing arg 2 of" "2nd incompatible" { target *-*-* } 15 } */
+/* { dg-warning "passing arg 1 of" "1st incompatible" { target *-*-* } 16 } */
+/* { dg-warning "passing arg 2 of" "2nd incompatible" { target *-*-* } 16 } */
+/* { dg-warning "passing arg 1 of" "1st incompatible" { target *-*-* } 18 } */
+/* { dg-warning "passing arg 1 of" "1st incompatible" { target *-*-* } 20 } */