Variant gcc-13
Applies to 13.2.0. Source flavors: linux, darwin_arm64.
+109 −14 4 files
gcc/c-family/c-ada-spec.cc
+51−14modified
| @@ -3115 +3115 @@is_abi_ignored_empty_field (tree node, tree field) | |||
| 3115 | 3115 | return false; | |
| 3116 | 3116 | } | |
| 3117 | 3117 | | |
| 3118 | Added line. /* Return true if FIELD is represented as a component in the generated Ada | ||
| 3119 | Added line. record. Keep this in step with dump_ada_structure. */ | ||
| 3120 | Added line. | ||
| 3121 | Added line. static bool | ||
| 3122 | Added line. is_ada_record_field (tree node, tree field) | ||
| 3123 | Added line. { | ||
| 3124 | Added line. if (TREE_CODE (field) != FIELD_DECL | ||
| 3125 | Added line. || DECL_VIRTUAL_P (field) | ||
| 3126 | Added line. || is_abi_ignored_empty_field (node, field)) | ||
| 3127 | Added line. return false; | ||
| 3128 | Added line. | ||
| 3129 | Added line. return DECL_NAME (field) || !is_tagged_type (TREE_TYPE (field)); | ||
| 3130 | Added line. } | ||
| 3131 | Added line. | ||
| 3118 | 3132 | /* Dump the value and object sizes of an empty C++ class. Ada's value size is | |
| 3119 | 3133 | zero so an empty base consumes no storage, while Object_Size preserves the | |
| 3120 | 3134 | byte occupied by a complete C++ object. */ | |
| @@ -2874 +2888 @@static bool | |||
| 2874 | 2888 | has_constant_field_layout (tree node) | |
| 2875 | 2889 | { | |
| 2876 | 2890 | for (tree field = TYPE_FIELDS (node); field; field = TREE_CHAIN (field)) | |
| 2877 | Removed line. if (TREE_CODE (field) == FIELD_DECL | ||
| 2878 | Removed line. && DECL_NAME (field) | ||
| 2879 | Removed line. && !DECL_VIRTUAL_P (field) | ||
| 2891 | Added line. if (is_ada_record_field (node, field) | ||
| 2880 | 2892 | && (!DECL_FIELD_OFFSET (field) | |
| 2881 | 2893 | || !DECL_FIELD_BIT_OFFSET (field) | |
| 2882 | 2894 | || !DECL_SIZE (field) | |
| @@ -2889 +2901 @@has_constant_field_layout (tree node) | |||
| 2889 | 2901 | return true; | |
| 2890 | 2902 | } | |
| 2891 | 2903 | | |
| 2892 | Removed line. /* Dump the size and component clauses needed to preserve NODE's C++ tail | ||
| 2893 | Removed line. padding layout. TYPE is the declaration used for Ada name qualification. */ | ||
| 2904 | Added line. /* Dump the size and component clauses needed to preserve NODE's C++ layout. | ||
| 2905 | Added line. For virtual inheritance the generated record contains the virtual bases and | ||
| 2906 | Added line. therefore uses the complete-object size; other calls preserve the as-base | ||
| 2907 | Added line. size needed for reusable tail padding. TYPE is the declaration used for | ||
| 2908 | Added line. Ada name qualification. */ | ||
| 2894 | 2909 | | |
| 2895 | 2910 | static void | |
| 2896 | Removed line. dump_ada_tail_padding_layout (pretty_printer *buffer, tree node, tree type, | ||
| 2897 | Removed line. int spc) | ||
| 2911 | Added line. dump_ada_cpp_layout (pretty_printer *buffer, tree node, tree type, int spc, | ||
| 2912 | Added line. bool has_virtual_base) | ||
| 2898 | 2913 | { | |
| 2899 | 2914 | const int data_size = cpp_check (node, GET_AS_BASE_SIZE); | |
| 2900 | 2915 | const HOST_WIDE_INT object_size = int_size_in_bytes (node); | |
| 2916 | Added line. const HOST_WIDE_INT value_size = has_virtual_base ? object_size : data_size; | ||
| 2901 | 2917 | | |
| 2902 | 2918 | gcc_assert (data_size >= 0 && object_size >= 0); | |
| 2903 | 2919 | | |
| @@ -2905 +2921 @@dump_ada_tail_padding_layout (pretty_printer *buffer, tree node, tree type, | |||
| 2905 | 2921 | pp_string (buffer, "for "); | |
| 2906 | 2922 | dump_ada_node (buffer, TYPE_NAME (node), type, spc, false, true); | |
| 2907 | 2923 | pp_string (buffer, "'Size use "); | |
| 2908 | Removed line. pp_wide_integer (buffer, (HOST_WIDE_INT) data_size * BITS_PER_UNIT); | ||
| 2924 | Added line. pp_wide_integer (buffer, value_size * BITS_PER_UNIT); | ||
| 2909 | 2925 | pp_semicolon (buffer); | |
| 2910 | 2926 | | |
| 2911 | 2927 | newline_and_indent (buffer, spc); | |
| @@ -2915 +2931 @@dump_ada_tail_padding_layout (pretty_printer *buffer, tree node, tree type, | |||
| 2915 | 2931 | pp_wide_integer (buffer, object_size * BITS_PER_UNIT); | |
| 2916 | 2932 | pp_semicolon (buffer); | |
| 2917 | 2933 | | |
| 2934 | Added line. if (has_virtual_base) | ||
| 2935 | Added line. { | ||
| 2936 | Added line. newline_and_indent (buffer, spc); | ||
| 2937 | Added line. pp_string (buffer, "for "); | ||
| 2938 | Added line. dump_ada_node (buffer, TYPE_NAME (node), type, spc, false, true); | ||
| 2939 | Added line. pp_string (buffer, "'Alignment use "); | ||
| 2940 | Added line. pp_decimal_int (buffer, TYPE_ALIGN (node) / BITS_PER_UNIT); | ||
| 2941 | Added line. pp_semicolon (buffer); | ||
| 2942 | Added line. } | ||
| 2943 | Added line. | ||
| 2918 | 2944 | newline_and_indent (buffer, spc); | |
| 2919 | 2945 | pp_string (buffer, "for "); | |
| 2920 | 2946 | dump_ada_node (buffer, TYPE_NAME (node), type, spc, false, true); | |
| 2921 | 2947 | pp_string (buffer, " use record"); | |
| 2922 | 2948 | | |
| 2949 | Added line. int field_num = 0; | ||
| 2923 | 2950 | for (tree field = TYPE_FIELDS (node); field; field = TREE_CHAIN (field)) | |
| 2924 | Removed line. if (TREE_CODE (field) == FIELD_DECL | ||
| 2925 | Removed line. && DECL_NAME (field) | ||
| 2926 | Removed line. && !DECL_VIRTUAL_P (field)) | ||
| 2951 | Added line. if (is_ada_record_field (node, field)) | ||
| 2927 | 2952 | { | |
| 2953 | Added line. field_num++; | ||
| 2928 | 2954 | const unsigned HOST_WIDE_INT bitpos | |
| 2929 | 2955 | = tree_to_uhwi (DECL_FIELD_OFFSET (field)) * BITS_PER_UNIT | |
| 2930 | 2956 | + tree_to_uhwi (DECL_FIELD_BIT_OFFSET (field)); | |
| @@ -2934 +2960 @@dump_ada_tail_padding_layout (pretty_printer *buffer, tree node, tree type, | |||
| 2934 | 2960 | = first_bit + tree_to_uhwi (DECL_SIZE (field)) - 1; | |
| 2935 | 2961 | | |
| 2936 | 2962 | newline_and_indent (buffer, spc + INDENT_INCR); | |
| 2937 | Removed line. dump_ada_decl_name (buffer, field, false); | ||
| 2963 | Added line. if (DECL_NAME (field)) | ||
| 2964 | Added line. dump_ada_decl_name (buffer, field, false); | ||
| 2965 | Added line. else if (field_num == 1) | ||
| 2966 | Added line. pp_string (buffer, "parent"); | ||
| 2967 | Added line. else | ||
| 2968 | Added line. { | ||
| 2969 | Added line. char buf[32]; | ||
| 2970 | Added line. sprintf (buf, "field_%d", field_num); | ||
| 2971 | Added line. pp_string (buffer, buf); | ||
| 2972 | Added line. } | ||
| 2938 | 2973 | pp_string (buffer, " at "); | |
| 2939 | 2974 | pp_unsigned_wide_integer (buffer, position); | |
| 2940 | 2975 | pp_string (buffer, " range "); | |
| @@ -3981 +4016 @@dump_ada_structure (pretty_printer *buffer, tree node, tree type, bool nested, | |||
| 3981 | 4016 | pp_newline (buffer); | |
| 3982 | 4017 | dump_ada_empty_class_layout (buffer, node, type, spc); | |
| 3983 | 4018 | } | |
| 3984 | Removed line. else if (needs_tail_padding_layout (node) | ||
| 4019 | Added line. else if ((needs_tail_padding_layout (node) | ||
| 4020 | Added line. || (cpp_check && cpp_check (node, HAS_VIRTUAL_BASE))) | ||
| 3985 | 4021 | && has_constant_field_layout (node)) | |
| 3986 | 4022 | { | |
| 3987 | 4023 | if (need_semicolon) | |
| @@ -3991 +4027 @@dump_ada_structure (pretty_printer *buffer, tree node, tree type, bool nested, | |||
| 3991 | 4027 | } | |
| 3992 | 4028 | | |
| 3993 | 4029 | pp_newline (buffer); | |
| 3994 | Removed line. dump_ada_tail_padding_layout (buffer, node, type, spc); | ||
| 4030 | Added line. dump_ada_cpp_layout (buffer, node, type, spc, | ||
| 4031 | Added line. cpp_check (node, HAS_VIRTUAL_BASE)); | ||
| 3995 | 4032 | } | |
| 3996 | 4033 | | |
| 3997 | 4034 | /* Print the static fields of the structure, if any. */ | |
gcc/c-family/c-ada-spec.h
+1−0modified
| @@ -27 +27 @@along with GCC; see the file COPYING3. If not see | |||
| 27 | 27 | enum cpp_operation { | |
| 28 | 28 | GET_AS_BASE_SIZE, | |
| 29 | 29 | GET_FUNCTION_QUALIFIERS, | |
| 30 | Added line. HAS_VIRTUAL_BASE, | ||
| 30 | 31 | HAS_DEPENDENT_TEMPLATE_ARGS, | |
| 31 | 32 | IS_ABSTRACT, | |
| 32 | 33 | IS_ASSIGNMENT_OPERATOR, | |
gcc/cp/decl2.cc
+3−0modified
| @@ -4439 +4439 @@cpp_check (tree t, cpp_operation op) | |||
| 4439 | 4439 | | |
| 4440 | 4440 | return qualifiers; | |
| 4441 | 4441 | } | |
| 4442 | Added line. case HAS_VIRTUAL_BASE: | ||
| 4443 | Added line. return (CLASS_TYPE_P (t) && COMPLETE_TYPE_P (t) | ||
| 4444 | Added line. && CLASSTYPE_VBASECLASSES (t)); | ||
| 4442 | 4445 | case HAS_DEPENDENT_TEMPLATE_ARGS: | |
| 4443 | 4446 | { | |
| 4444 | 4447 | tree ti = CLASSTYPE_TEMPLATE_INFO (t); | |
gcc/testsuite/g++.dg/ada-spec/virtual-inheritance-layout.C
+54−0new file
| @@ -0 +1 @@ | |||
| 1 | Added line. /* { dg-do compile } */ | ||
| 2 | Added line. /* { dg-require-effective-target lp64 } */ | ||
| 3 | Added line. /* { dg-options "-fdump-ada-spec-slim" } */ | ||
| 4 | Added line. /* { dg-final { scan-file virtual_inheritance_layout_c.ads "for Virtual'Size use 128;" } } */ | ||
| 5 | Added line. /* { dg-final { scan-file virtual_inheritance_layout_c.ads "for Virtual'Object_Size use 128;" } } */ | ||
| 6 | Added line. /* { dg-final { scan-file virtual_inheritance_layout_c.ads "for Virtual'Alignment use 8;" } } */ | ||
| 7 | Added line. /* { dg-final { scan-file virtual_inheritance_layout_c.ads "derived_value at 8 range 0 .. 31;" } } */ | ||
| 8 | Added line. /* { dg-final { scan-file virtual_inheritance_layout_c.ads "field_2 at 12 range 0 .. 31;" } } */ | ||
| 9 | Added line. | ||
| 10 | Added line. struct Root | ||
| 11 | Added line. { | ||
| 12 | Added line. int root_value; | ||
| 13 | Added line. }; | ||
| 14 | Added line. | ||
| 15 | Added line. struct Virtual : virtual Root | ||
| 16 | Added line. { | ||
| 17 | Added line. int derived_value; | ||
| 18 | Added line. Virtual (int root, int derived); | ||
| 19 | Added line. }; | ||
| 20 | Added line. | ||
| 21 | Added line. Virtual::Virtual (int root, int derived) | ||
| 22 | Added line. : Root {root}, derived_value {derived} | ||
| 23 | Added line. {} | ||
| 24 | Added line. | ||
| 25 | Added line. extern "C" unsigned long cpp_root_size () { return sizeof (Root); } | ||
| 26 | Added line. extern "C" unsigned long cpp_virtual_size () { return sizeof (Virtual); } | ||
| 27 | Added line. extern "C" unsigned long cpp_virtual_alignment () { return alignof (Virtual); } | ||
| 28 | Added line. extern "C" unsigned long cpp_derived_offset () | ||
| 29 | Added line. { | ||
| 30 | Added line. Virtual object (0, 0); | ||
| 31 | Added line. return reinterpret_cast<char *> (&object.derived_value) | ||
| 32 | Added line. - reinterpret_cast<char *> (&object); | ||
| 33 | Added line. } | ||
| 34 | Added line. extern "C" unsigned long cpp_root_offset () | ||
| 35 | Added line. { | ||
| 36 | Added line. Virtual object (0, 0); | ||
| 37 | Added line. return reinterpret_cast<char *> (&object.root_value) | ||
| 38 | Added line. - reinterpret_cast<char *> (&object); | ||
| 39 | Added line. } | ||
| 40 | Added line. extern "C" Virtual *cpp_create (int root, int derived) | ||
| 41 | Added line. { | ||
| 42 | Added line. return new Virtual (root, derived); | ||
| 43 | Added line. } | ||
| 44 | Added line. extern "C" void cpp_delete (Virtual *object) { delete object; } | ||
| 45 | Added line. extern "C" int cpp_root_value (const Virtual *object) | ||
| 46 | Added line. { | ||
| 47 | Added line. return object->root_value; | ||
| 48 | Added line. } | ||
| 49 | Added line. extern "C" int cpp_derived_value (const Virtual *object) | ||
| 50 | Added line. { | ||
| 51 | Added line. return object->derived_value; | ||
| 52 | Added line. } | ||
| 53 | Added line. | ||
| 54 | Added line. /* { dg-final { cleanup-ada-spec } } */ | ||
| 55 | | ||