fix for __builtin_size_t

Jan Beulich JBeulich@novell.com
Wed Jul 7 12:12:00 GMT 2004


bootstrapped and tested on x86_64-unknown-linux-gnu.

2004-07-07 Jan Beulich <jbeulich@novell.com>

	* c-common.c (c_common_nodes_and_builtins): Use size_type_node
	instead of sizenode for __builtin_size_t.

testsuite:
2004-07-07 Jan Beulich <jbeulich@novell.com>

	* gcc.dg/builtin-size_t: New test for bogus warning when using
	__builtin_size_t.
	* gcc.dg/format/builtin_size_t: Dito.

---
/home/jbeulich/src/gcc/mainline/2004-07-05.10.09/gcc/c-common.c	2004-07-02
15:13:11.000000000 +0200
+++ 2004-07-05.10.09/gcc/c-common.c	2004-07-06 17:16:41.227547552
+0200
@@ -2979,7 +2979,7 @@
 
   lang_hooks.decls.pushdecl
     (build_decl (TYPE_DECL, get_identifier ("__builtin_size_t"),
-		 sizetype));
+		 size_type_node));
 
   if (TREE_CODE (va_list_type_node) == ARRAY_TYPE)
     {
---
/home/jbeulich/src/gcc/mainline/2004-07-05.10.09/gcc/testsuite/gcc.dg/builtin-size_t.c	1970-01-01
01:00:00.000000000 +0100
+++
2004-07-05.10.09/gcc/testsuite/gcc.dg/builtin-size_t.c	2004-05-28
13:45:11.000000000 +0200
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+
+typedef __builtin_size_t size_t;
+
+size_t large = (size_t)1 & ~(((size_t)0x10) - 1); /* { dg-bogus "large
integer implicitly truncated" } */
+
+size_t test(size_t size) {
+	return size & ~(((size_t)0x10) - 1); /* { dg-bogus "large
integer implicitly truncated" } */
+}
---
/home/jbeulich/src/gcc/mainline/2004-07-05.10.09/gcc/testsuite/gcc.dg/format/builtin_size_t.c	1970-01-01
01:00:00.000000000 +0100
+++
2004-07-05.10.09/gcc/testsuite/gcc.dg/format/builtin_size_t.c	2004-06-01
16:55:00.000000000 +0200
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-options "-Wformat" } */
+
+typedef __builtin_size_t size_t;
+
+int printf(const char*, ...);
+
+void test1(size_t sz) {
+	printf("%zu\n", sz); /* { dg-bogus "format" } */
+}
+
+typedef size_t other_t;
+
+void test2(other_t sz) {
+	printf("%zu\n", sz); /* { dg-bogus "format" } */
+}

-------------- next part --------------
A non-text attachment was scrubbed...
Name: gcc-mainline-size_t.patch
Type: application/octet-stream
Size: 1834 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20040707/34a61671/attachment.obj>


More information about the Gcc-patches mailing list