@@ -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);*/
}
@@ -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 }