]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: reorder contract_violation
authorJason Merrill <jason@redhat.com>
Tue, 1 Nov 2022 14:38:02 +0000 (10:38 -0400)
committerJason Merrill <jason@redhat.com>
Wed, 2 Nov 2022 15:04:00 +0000 (11:04 -0400)
Moving the int after the pointers makes the object one word smaller.

gcc/cp/contracts.cc
libstdc++-v3/include/experimental/contract
libstdc++-v3/src/experimental/contract.cc

index 6732b761183cbf360b6d940a930d1422c88df0a9..3a0377089a08fea091e1fdff50b7d054c7c16dc8 100644 (file)
@@ -1599,21 +1599,21 @@ get_pseudo_contract_violation_type ()
     {
       /* Must match <contract>:
         class contract_violation {
-          uint_least32_t _M_line;
           const char* _M_file;
           const char* _M_function;
           const char* _M_comment;
           const char* _M_level;
           const char* _M_role;
+          uint_least32_t _M_line;
           signed char _M_continue;
         If this changes, also update the initializer in
         build_contract_violation.  */
-      const tree types[] = { uint_least32_type_node,
-                            const_string_type_node,
+      const tree types[] = { const_string_type_node,
                             const_string_type_node,
                             const_string_type_node,
                             const_string_type_node,
                             const_string_type_node,
+                            uint_least32_type_node,
                             signed_char_type_node };
       tree fields = NULL_TREE;
       for (tree type : types)
@@ -1663,12 +1663,12 @@ build_contract_violation (tree contract, contract_continuation cmode)
   /* Must match the type layout in get_pseudo_contract_violation_type.  */
   tree ctor = build_constructor_va
     (init_list_type_node, 7,
-     NULL_TREE, build_int_cst (uint_least32_type_node, loc.line),
      NULL_TREE, build_string_literal (loc.file),
      NULL_TREE, build_string_literal (function),
      NULL_TREE, CONTRACT_COMMENT (contract),
      NULL_TREE, build_string_literal (level),
      NULL_TREE, build_string_literal (role),
+     NULL_TREE, build_int_cst (uint_least32_type_node, loc.line),
      NULL_TREE, build_int_cst (signed_char_type_node, cmode));
 
   ctor = finish_compound_literal (get_pseudo_contract_violation_type (),
index fb03f116847f18a318b4100b48812dc9a07d1215..16f3fd5fd5a256023cbc4d735a87dd888e40ae18 100644 (file)
@@ -52,12 +52,12 @@ namespace experimental
   };
 
   class contract_violation {
-    uint_least32_t _M_line;
     const char* _M_file;
     const char* _M_function;
     const char* _M_comment;
     const char* _M_level;
     const char* _M_role;
+    uint_least32_t _M_line;
     signed char _M_continue;
   public:
     // From N4820
index f1b6eb3a58adbd9bd03bab49915c56b87bfec188..b9b72cd7df0ab8f7329f00f3091165857c87a82a 100644 (file)
@@ -38,3 +38,4 @@ handle_contract_violation (const std::experimental::contract_violation &violatio
     << " " << (int)violation.continuation_mode()
     << std::endl;
 }
+