@@ -1335,6 +1335,9 @@ digest_nsdmi_init (tree decl, tree init,
gcc_assert (TREE_CODE (decl) == FIELD_DECL);
tree type = TREE_TYPE (decl);
+ if (DECL_BIT_FIELD_TYPE (decl))
+ type = cp_build_qualified_type (DECL_BIT_FIELD_TYPE (decl),
+ cp_type_quals (type));
int flags = LOOKUP_IMPLICIT;
if (DIRECT_LIST_INIT_P (init))
{
@@ -15,11 +15,9 @@ const int b = 0;
struct S {
int c : 5 = 2 * a; // { dg-warning "default member initializers for bit-fields only available with" "" { target c++17_down } }
int d : 6 { c + a }; // { dg-warning "default member initializers for bit-fields only available with" "" { target c++17_down } }
- // { dg-warning "narrowing conversion of" "" { target *-*-* } .-1 }
int e : true ? 7 : a = 3;
int f : (true ? 8 : b) = d + a; // { dg-warning "default member initializers for bit-fields only available with" "" { target c++17_down } }
int g : (true ? 9 : b) { f + a }; // { dg-warning "default member initializers for bit-fields only available with" "" { target c++17_down } }
- // { dg-warning "narrowing conversion of" "" { target *-*-* } .-1 }
int h : 1 || new int { 0 };
int i = g + a;
};
@@ -28,11 +26,9 @@ template <bool V, int W>
struct U {
int j : W = 3 * a; // { dg-warning "default member initializers for bit-fields only available with" "" { target c++17_down } }
int k : W { j + a }; // { dg-warning "default member initializers for bit-fields only available with" "" { target c++17_down } }
- // { dg-warning "narrowing conversion of" "" { target *-*-* } .-1 }
int l : V ? 7 : a = 3;
int m : (V ? W : b) = k + a; // { dg-warning "default member initializers for bit-fields only available with" "" { target c++17_down } }
int n : (V ? W : b) { m + a }; // { dg-warning "default member initializers for bit-fields only available with" "" { target c++17_down } }
- // { dg-warning "narrowing conversion of" "" { target *-*-* } .-1 }
int o : 1 || new int { 0 };
int p = n + a;
};
@@ -0,0 +1,12 @@
+// PR c++/92732
+// { dg-do compile { target c++17 } }
+// { dg-options "" }
+
+enum class byte : unsigned char { };
+using uint8_t = unsigned char;
+
+struct T
+{
+ byte a : 2 = byte{0}; // { dg-warning "default member initializers for bit-fields only available with" "" { target c++17_down } }
+ uint8_t b : 2 = 0; // { dg-warning "default member initializers for bit-fields only available with" "" { target c++17_down } }
+} t;