aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2007-09-06 01:27:17 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2007-09-06 01:27:17 +0200
commit012c4da9f1989cb7227942559edddd57957733c1 (patch)
tree25366d4fc41359e214da9a68ae0144b9522f8311
parent62bedd31edd62e473fceb5c75b838e4c4f5079fe (diff)
downloadgcc-012c4da9f1989cb7227942559edddd57957733c1.zip
gcc-012c4da9f1989cb7227942559edddd57957733c1.tar.gz
gcc-012c4da9f1989cb7227942559edddd57957733c1.tar.bz2
re PR c++/33289 (__sprintf_chk etc. not DECL_ANTICIPATED)
PR c++/33289 * decl.c (builtin_function_1): Set DECL_ANTICIPATED also on __*_chk non-__builtin_* decls. * g++.dg/eh/builtin4.C: New test. From-SVN: r128160
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/decl.c11
-rw-r--r--gcc/testsuite/ChangeLog3
-rw-r--r--gcc/testsuite/g++.dg/eh/builtin4.C6
4 files changed, 24 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 07663ed..b8fb971 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -3,6 +3,10 @@
* decl.c (duplicate_decls): Set TREE_NOTHROW on __builtin_XX
decl if a prototype for XX is provided with throw().
+ PR c++/33289
+ * decl.c (builtin_function_1): Set DECL_ANTICIPATED also
+ on __*_chk non-__builtin_* decls.
+
2007-09-05 Paolo Carlini <pcarlini@suse.de>
PR c++/30302
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 311925a..9587de5 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -3528,6 +3528,17 @@ builtin_function_1 (tree decl, tree context)
anticipated but not actually declared. */
if (name[0] != '_' || name[1] != '_')
DECL_ANTICIPATED (decl) = 1;
+ else if (strncmp (name + 2, "builtin_", strlen ("builtin_")) != 0)
+ {
+ size_t len = strlen (name);
+
+ /* Treat __*_chk fortification functions as anticipated as well,
+ unless they are __builtin_*. */
+ if (len > strlen ("___chk")
+ && memcmp (name + len - strlen ("_chk"),
+ "_chk", strlen ("_chk") + 1) == 0)
+ DECL_ANTICIPATED (decl) = 1;
+ }
return decl;
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 41ca76d..e6803a8 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -4,6 +4,9 @@
* g++.dg/eh/builtin2.C: New test.
* g++.dg/eh/builtin3.C: New test.
+ PR c++/33289
+ * g++.dg/eh/builtin4.C: New test.
+
2007-09-05 Janis Johnson <janis187@us.ibm.com>
* gcc.target/powerpc/dfp-dd.c: New test.
diff --git a/gcc/testsuite/g++.dg/eh/builtin4.C b/gcc/testsuite/g++.dg/eh/builtin4.C
new file mode 100644
index 0000000..3234817
--- /dev/null
+++ b/gcc/testsuite/g++.dg/eh/builtin4.C
@@ -0,0 +1,6 @@
+// PR c++/33289
+// { dg-do compile }
+
+typedef __SIZE_TYPE__ size_t;
+extern "C" int __sprintf_chk (char *__restrict, int, size_t, const char *, ...) throw ();
+extern "C" int __sprintf_chk (char *__restrict, int, size_t, const char *, ...) throw ();