gcc/gcc41-builtin-chk-anticipated.patch
Jakub Jelinek 2d7fb2fe4b 4.1.2-22
2007-09-06 12:26:46 +00:00

38 lines
1.3 KiB
Diff

2007-09-06 Jakub Jelinek <jakub@redhat.com>
PR c++/33289
* decl.c (builtin_function_1): Set DECL_ANTICIPATED also
on __*_chk non-__builtin_* decls.
* g++.dg/eh/builtin4.C: New test.
--- gcc/cp/decl.c.jj 2007-08-31 14:28:19.000000000 +0200
+++ gcc/cp/decl.c 2007-09-04 21:28:06.000000000 +0200
@@ -3517,6 +3529,17 @@ builtin_function_1 (tree decl, tree cont
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;
}
--- gcc/testsuite/g++.dg/eh/builtin4.C.jj 2007-09-04 22:06:06.000000000 +0200
+++ gcc/testsuite/g++.dg/eh/builtin4.C 2007-09-04 22:07:03.000000000 +0200
@@ -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 ();