This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++ PATCH] Fix handling of __java_* builtin types (PR c++/46001)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Jason Merrill <jason at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Wed, 3 Nov 2010 18:47:28 +0100
- Subject: [C++ PATCH] Fix handling of __java_* builtin types (PR c++/46001)
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
My patch to cache build_nonstandard_integer_type types broke
this testcase, as for the __java_* types we set TYPE_NAME on
the returned type. Fixed by using a distinct type copy instead.
Bootstrapped/regtested on x86_64-linux and i686-linux. Ok for trunk?
2010-11-03 Jakub Jelinek <jakub@redhat.com>
PR c++/46001
* decl.c (record_builtin_java_type): Call build_distinct_type_copy
on build_nonstandard_integer_type result for __java_* types.
* g++.dg/diagnostic/bitfld1.C: New test.
--- gcc/cp/decl.c.jj 2010-11-01 09:07:00.000000000 +0100
+++ gcc/cp/decl.c 2010-11-03 15:22:50.000000000 +0100
@@ -3322,17 +3322,22 @@ record_builtin_java_type (const char* na
{
tree type, decl;
if (size > 0)
- type = build_nonstandard_integer_type (size, 0);
+ {
+ type = build_nonstandard_integer_type (size, 0);
+ type = build_distinct_type_copy (type);
+ }
else if (size > -32)
{
tree stype;
/* "__java_char" or ""__java_boolean". */
type = build_nonstandard_integer_type (-size, 1);
+ type = build_distinct_type_copy (type);
/* Get the signed type cached and attached to the unsigned type,
so it doesn't get garbage-collected at "random" times,
causing potential codegen differences out of different UIDs
and different alias set numbers. */
stype = build_nonstandard_integer_type (-size, 0);
+ stype = build_distinct_type_copy (stype);
TREE_CHAIN (type) = stype;
/*if (size == -1) TREE_SET_CODE (type, BOOLEAN_TYPE);*/
}
--- gcc/testsuite/g++.dg/diagnostic/bitfld1.C.jj 2010-11-03 15:33:05.000000000 +0100
+++ gcc/testsuite/g++.dg/diagnostic/bitfld1.C 2010-11-03 15:32:31.000000000 +0100
@@ -0,0 +1,13 @@
+// PR c++/46001
+// { dg-do compile }
+
+struct S
+{
+ char *p;
+ unsigned char f : 1;
+};
+
+struct S s;
+void *a = s.p | s.f; // { dg-error "unsigned char:1" }
+
+// { dg-bogus "__java_boolean" "" { target *-*-* } 11 }
Jakub