re PR c++/13070 (-Wformat option ignored in g++)
authorRoger Sayle <roger@eyesopen.com>
Sun, 28 Dec 2003 22:22:13 +0000 (22:22 +0000)
committerRoger Sayle <sayle@gcc.gnu.org>
Sun, 28 Dec 2003 22:22:13 +0000 (22:22 +0000)
PR c++/13070
* decl.c (duplicate_decls): When setting the type of an anticipated
declaration, merge the existing type attributes.

* g++.dg/warn/format3.C: New test case.

From-SVN: r75185

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/warn/format3.C [new file with mode: 0644]

index 4adb918f355ffa46b405994a74c5dce8be3071ee..1d96aaf333692d91f85bedcc265fbcbdad6d4e60 100644 (file)
@@ -1,3 +1,9 @@
+2003-12-28  Roger Sayle  <roger@eyesopen.com>
+
+       PR c++/13070
+       * decl.c (duplicate_decls): When setting the type of an anticipated
+       declaration, merge the existing type attributes.
+
 2003-12-25  Andrew Pinski  <pinskia@physics.uc.edu>
 
        PR c++/13268, c++/13339
index 09b002201cc10e58cfa92dd28531429945e2c91e..0c0803b7c7e6782cc64ddb3c8f26b40fcc82f470 100644 (file)
@@ -1261,7 +1261,12 @@ duplicate_decls (tree newdecl, tree olddecl)
       /* Even if the types match, prefer the new declarations type
         for anticipated built-ins, for exception lists, etc...  */
       else if (DECL_ANTICIPATED (olddecl))
-       TREE_TYPE (olddecl) = TREE_TYPE (newdecl);
+       {
+         TYPE_ATTRIBUTES (TREE_TYPE (newdecl))
+           = (*targetm.merge_type_attributes) (TREE_TYPE (olddecl),
+                                               TREE_TYPE (newdecl));
+         TREE_TYPE (olddecl) = TREE_TYPE (newdecl);
+       }
 
       /* Whether or not the builtin can throw exceptions has no
         bearing on this declarator.  */
index b124d1309817fbea43d850a98f481fa7f941cc27..6f601e3155540b84ff63053550d63b4862cf0809 100644 (file)
@@ -1,3 +1,8 @@
+2003-12-28  Roger Sayle  <roger@eyesopen.com>
+
+       PR c++/13070
+       * g++.dg/warn/format3.C: New test case.
+
 2003-12-27  Zdenek Dvorak  <rakdver@atrey.karlin.mff.cuni.cz>
 
        * gcc.c-torture/compile/20031227-1.c: New test.
diff --git a/gcc/testsuite/g++.dg/warn/format3.C b/gcc/testsuite/g++.dg/warn/format3.C
new file mode 100644 (file)
index 0000000..0bdaaee
--- /dev/null
@@ -0,0 +1,12 @@
+// PR c++/13070
+// { dg-do compile }
+// { dg-options "-Wformat" }
+
+extern "C" int printf (const char*, ...);
+
+int main()
+{
+  printf("%d\n", 1, 1);  // { dg-warning "too many" "printf warning" }
+  return 0;
+}
+