diff mbox

[C++] Fix handling of __java_* builtin types (PR c++/46001)

Message ID 20101103174728.GS29412@tyan-ft48-01.lab.bos.redhat.com
State New
Headers show

Commit Message

Jakub Jelinek Nov. 3, 2010, 5:47 p.m. UTC
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.


	Jakub

Comments

Jason Merrill Dec. 10, 2010, 4:16 p.m. UTC | #1
OK.

Jason
diff mbox

Patch

--- 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 }