re PR c++/13507 (spurious printf format warning)
authorNathan Sidwell <nathan@codesourcery.com>
Tue, 30 Dec 2003 12:18:28 +0000 (12:18 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Tue, 30 Dec 2003 12:18:28 +0000 (12:18 +0000)
cp:
PR c++/13507
* decl.c (duplicate_decls): Use build_type_attribute_variant to
merge attributes.
testsuite:
PR c++/13507
* g++.dg/ext/attrib11.C: New test.

From-SVN: r75229

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

index 15947ba7a3b3c400b4c14264238dfef07e0c3e13..d56d24cc3ace467a0df500f0c63327fa6abaf2b0 100644 (file)
@@ -1,5 +1,9 @@
 2003-12-30  Nathan Sidwell  <nathan@codesourcery.com>
 
+       PR c++/13507
+       * decl.c (duplicate_decls): Use build_type_attribute_variant to
+       merge attributes.
+
        PR c++/13494
        * tree.c (build_cplus_array_type_1): Only build a minimal array
        type for dependent types or domains.
index 80041cb614ddbbeb32c2740b75700a3ba616a1de..c7a294d9b2f78e76bfe27f2e76db4f4ee822ff1a 100644 (file)
@@ -1262,10 +1262,12 @@ duplicate_decls (tree newdecl, tree olddecl)
         for anticipated built-ins, for exception lists, etc...  */
       else if (DECL_ANTICIPATED (olddecl))
        {
-         TYPE_ATTRIBUTES (TREE_TYPE (newdecl))
-           = (*targetm.merge_type_attributes) (TREE_TYPE (olddecl),
-                                               TREE_TYPE (newdecl));
-         TREE_TYPE (olddecl) = TREE_TYPE (newdecl);
+         tree type = TREE_TYPE (newdecl);
+         tree attribs = (*targetm.merge_type_attributes)
+           (TREE_TYPE (olddecl), type);
+
+         type = build_type_attribute_variant (type, attribs);
+         TREE_TYPE (newdecl) = TREE_TYPE (olddecl) = type;
        }
 
       /* Whether or not the builtin can throw exceptions has no
index 992e6f4345a892d2bb94fe4256b6f6eb6d95f028..d13331fdfd9fd6edf1900d7f51256e970867227e 100644 (file)
@@ -1,5 +1,8 @@
 2003-12-30  Nathan Sidwell  <nathan@codesourcery.com>
 
+       PR c++/13507
+       * g++.dg/ext/attrib11.C: New test.
+
        PR c++/13494
        * g++.dg/template/array2-1.C: New test.
        * g++.dg/template/array2-2.C: New test.
diff --git a/gcc/testsuite/g++.dg/ext/attrib11.C b/gcc/testsuite/g++.dg/ext/attrib11.C
new file mode 100644 (file)
index 0000000..26bc790
--- /dev/null
@@ -0,0 +1,17 @@
+// { dg-do compile }
+// { dg-options "-Wall" }
+
+// Copyright (C) 2003 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 30 Dec 2003 <nathan@codesourcery.com>
+
+
+// PR c++/13507, spurious warning due to attribute clobbering
+extern "C" {
+  extern int printf (__const char *__restrict __format, ...) throw ();
+  extern int scanf (__const char *__restrict __format, ...) throw ();
+}
+
+void foo(unsigned int x)
+{
+  printf ("%d\n", x);
+}