diff options
author | Roger Sayle <roger@eyesopen.com> | 2003-12-28 22:22:13 +0000 |
---|---|---|
committer | Roger Sayle <sayle@gcc.gnu.org> | 2003-12-28 22:22:13 +0000 |
commit | 7072018ecfcc4d60e3ad9f5d8a078f672da6817f (patch) | |
tree | 262d2a607a95dec54bce24da831eafc241a99005 | |
parent | 9f88b919e0b01c429ac064c44338ef55a8484fee (diff) | |
download | gcc-7072018ecfcc4d60e3ad9f5d8a078f672da6817f.zip gcc-7072018ecfcc4d60e3ad9f5d8a078f672da6817f.tar.gz gcc-7072018ecfcc4d60e3ad9f5d8a078f672da6817f.tar.bz2 |
re PR c++/13070 (-Wformat option ignored in g++)
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
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/decl.c | 7 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/warn/format3.C | 12 |
4 files changed, 29 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 4adb918..1d96aaf 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -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 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 09b0022..0c0803b7 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -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. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b124d13..6f601e3 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -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 index 0000000..0bdaaee --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/format3.C @@ -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; +} + |