From fa13cfd08aff3bfc2d119c1727f6107e91774eb4 Mon Sep 17 00:00:00 2001 From: Arthur Cohen Date: Fri, 28 Jul 2023 14:33:34 +0200 Subject: [PATCH] gccrs: error codes: Add rust_error_codes.def, refactor ErrorCode enum gcc/rust/ChangeLog: * rust-diagnostics.cc: Rework `make_description` and `make_url` functions. * rust-diagnostics.h: Specify ErrorCode's underlying type, remove error_codes_strings table. * rust_error_codes.def: New file. --- gcc/rust/rust-diagnostics.cc | 31 +- gcc/rust/rust-diagnostics.h | 1058 +-------------------------------- gcc/rust/rust_error_codes.def | 506 ++++++++++++++++ 3 files changed, 556 insertions(+), 1039 deletions(-) create mode 100644 gcc/rust/rust_error_codes.def diff --git a/gcc/rust/rust-diagnostics.cc b/gcc/rust/rust-diagnostics.cc index cb813d453f9..6b99ab5f6c9 100644 --- a/gcc/rust/rust-diagnostics.cc +++ b/gcc/rust/rust-diagnostics.cc @@ -197,15 +197,40 @@ class rust_error_code_rule : public diagnostic_metadata::rule public: rust_error_code_rule (const ErrorCode code) : m_code (code) {} + void format_error_code (char *buffer) const + { + static_assert ( + std::is_same::type, unsigned int>::value, + "invalid format specifier for ErrorCode's underlying type"); + + snprintf (buffer, 6, "E%04u", + (std::underlying_type::type) m_code); + } + char *make_description () const final override { - return xstrdup (error_code_strings.at (m_code)); + // 'E' + 4 characters + \0 + char *buffer = new char[6]; + + // is that needed. does C++ suck that much that you + // can't zero initialize a new[]'d char array + memset (buffer, 0, 6); + + format_error_code (buffer); + + // we can use the `u` format specifier because the `ErrorCode` enum class + // "inherits" from `unsigned int` - add a static assertion to make sure + // that's the case before we do the formatting + + return buffer; } char *make_url () const final override { - return concat ("https://doc.rust-lang.org/error-index.html#", - error_code_strings.at (m_code), NULL); + char buffer[6] = {0}; + format_error_code (buffer); + + return concat ("https://doc.rust-lang.org/error-index.html#", buffer, NULL); } private: diff --git a/gcc/rust/rust-diagnostics.h b/gcc/rust/rust-diagnostics.h index 552689136ef..a2546348cfe 100644 --- a/gcc/rust/rust-diagnostics.h +++ b/gcc/rust/rust-diagnostics.h @@ -48,1047 +48,33 @@ // All other format specifiers are as defined by 'sprintf'. The final resulting // message is then sent to the back end via rust_be_error_at/rust_be_warning_at. -// clang-format off // simple location // https://gist.github.com/MahadMuhammad/8c9d5fc88ea18d8c520937a8071d4185 -enum class ErrorCode -{ - E0001, // this error code is no longer emitted by the compiler - E0002, // this error code is no longer emitted by the compiler - E0004, - E0005, - E0007, // this error code is no longer emitted by the compiler - E0009, // this error code is no longer emitted by the compiler - E0010, - E0013, - E0014, // this error code is no longer emitted by the compiler - E0015, - E0023, - E0025, - E0026, - E0027, - E0029, - E0030, - E0033, - E0034, - E0038, - E0040, - E0044, - E0045, - E0046, - E0049, - E0050, - E0053, - E0054, - E0055, - E0057, - E0059, - E0060, - E0061, - E0062, - E0063, - E0067, - E0069, - E0070, - E0071, - E0072, - E0073, // this error code is no longer emitted by the compiler - E0074, // this error code is no longer emitted by the compiler - E0075, - E0076, - E0077, - E0080, - E0081, - E0084, - E0087, // this error code is no longer emitted by the compiler - E0088, // this error code is no longer emitted by the compiler - E0089, // this error code is no longer emitted by the compiler - E0090, // this error code is no longer emitted by the compiler - E0091, - E0092, - E0093, - E0094, - E0106, - E0107, - E0109, - E0110, // this error code is no longer emitted by the compiler - E0116, - E0117, - E0118, - E0119, - E0120, - E0121, - E0124, - E0128, - E0130, - E0131, - E0132, - E0133, - E0136, // this error code is no longer emitted by the compiler - E0137, // this error code is no longer emitted by the compiler - E0138, - E0139, // this error code is no longer emitted by the compiler - E0152, - E0154, // this error code is no longer emitted by the compiler - E0158, - E0161, - E0162, // this error code is no longer emitted by the compiler - E0164, - E0165, // this error code is no longer emitted by the compiler - E0170, - E0178, - E0183, - E0184, - E0185, - E0186, - E0191, - E0192, // this error code is no longer emitted by the compiler - E0193, // this error code is no longer emitted by the compiler - E0195, - E0197, - E0198, - E0199, - E0200, - E0201, - E0203, - E0204, - E0205, // this error code is no longer emitted by the compiler - E0206, - E0207, - E0208, // this error code is no longer emitted by the compiler - E0210, - E0211, // this error code is no longer emitted by the compiler - E0212, - E0214, - E0220, - E0221, - E0222, - E0223, - E0224, - E0225, - E0226, - E0227, - E0228, - E0229, - E0230, - E0231, - E0232, - E0243, // this error code is no longer emitted by the compiler - E0244, // this error code is no longer emitted by the compiler - E0251, // this error code is no longer emitted by the compiler - E0252, - E0253, - E0254, - E0255, - E0256, // this error code is no longer emitted by the compiler - E0259, - E0260, - E0261, - E0262, - E0263, // this error code is no longer emitted by the compiler - E0264, - E0267, - E0268, - E0271, - E0275, - E0276, - E0277, - E0281, // this error code is no longer emitted by the compiler - E0282, - E0283, - E0284, - E0297, // this error code is no longer emitted by the compiler - E0301, // this error code is no longer emitted by the compiler - E0302, // this error code is no longer emitted by the compiler - E0303, // this error code is no longer emitted by the compiler - E0307, - E0308, - E0309, - E0310, - E0311, - E0312, // this error code is no longer emitted by the compiler - E0316, - E0317, - E0320, - E0321, - E0322, - E0323, - E0324, - E0325, - E0326, - E0328, - E0329, // this error code is no longer emitted by the compiler - E0364, - E0365, - E0366, - E0367, - E0368, - E0369, - E0370, - E0371, - E0373, - E0374, - E0375, - E0376, - E0377, - E0378, - E0379, - E0380, - E0381, - E0382, - E0383, // this error code is no longer emitted by the compiler - E0384, - E0386, // this error code is no longer emitted by the compiler - E0387, // this error code is no longer emitted by the compiler - E0388, // this error code is no longer emitted by the compiler - E0389, // this error code is no longer emitted by the compiler - E0390, - E0391, - E0392, - E0393, - E0398, // this error code is no longer emitted by the compiler - E0399, - E0401, - E0403, - E0404, - E0405, - E0407, - E0408, - E0409, - E0411, - E0412, - E0415, - E0416, - E0422, - E0423, - E0424, - E0425, - E0426, - E0428, - E0429, - E0430, - E0431, - E0432, - E0433, - E0434, - E0435, - E0436, - E0437, - E0438, - E0439, // this error code is no longer emitted by the compiler - E0445, - E0446, - E0447, // this error code is no longer emitted by the compiler - E0448, // this error code is no longer emitted by the compiler - E0449, - E0451, - E0452, - E0453, - E0454, - E0455, - E0457, - E0458, - E0459, - E0460, - E0461, - E0462, - E0463, - E0464, - E0466, - E0468, - E0469, - E0472, - E0476, - E0477, // this error code is no longer emitted by the compiler - E0478, - E0482, // this error code is no longer emitted by the compiler - E0491, - E0492, - E0493, - E0495, // this error code is no longer emitted by the compiler - E0496, - E0497, // this error code is no longer emitted by the compiler - E0498, - E0499, - E0500, - E0501, - E0502, - E0503, - E0504, // this error code is no longer emitted by the compiler - E0505, - E0506, - E0507, - E0508, - E0509, - E0510, - E0511, - E0512, - E0514, - E0515, - E0516, - E0517, - E0518, - E0519, - E0520, - E0521, - E0522, - E0523, // this error code is no longer emitted by the compiler - E0524, - E0525, - E0527, - E0528, - E0529, - E0530, - E0531, - E0532, - E0533, - E0534, - E0535, - E0536, - E0537, - E0538, - E0539, - E0541, - E0542, - E0543, - E0544, - E0545, - E0546, - E0547, - E0549, - E0550, - E0551, - E0552, - E0554, - E0556, - E0557, - E0559, - E0560, - E0561, - E0562, - E0565, - E0566, - E0567, - E0568, - E0569, - E0570, - E0571, - E0572, - E0573, - E0574, - E0575, - E0576, - E0577, - E0578, - E0579, - E0580, - E0581, - E0582, - E0583, - E0584, - E0585, - E0586, - E0587, - E0588, - E0589, - E0590, - E0591, - E0592, - E0593, - E0594, - E0595, // this error code is no longer emitted by the compiler - E0596, - E0597, - E0599, - E0600, - E0601, - E0602, - E0603, - E0604, - E0605, - E0606, - E0607, - E0608, - E0609, - E0610, - E0614, - E0615, - E0616, - E0617, - E0618, - E0619, // this error code is no longer emitted by the compiler - E0620, - E0621, - E0622, - E0623, - E0624, - E0625, - E0626, - E0627, - E0628, - E0631, - E0632, // this error code is no longer emitted by the compiler - E0633, // this error code is no longer emitted by the compiler - E0634, - E0635, - E0636, - E0637, - E0638, - E0639, - E0640, - E0641, - E0642, - E0643, - E0644, - E0646, - E0647, - E0648, - E0657, - E0658, - E0659, - E0660, // this error code is no longer emitted by the compiler - E0661, // this error code is no longer emitted by the compiler - E0662, // this error code is no longer emitted by the compiler - E0663, // this error code is no longer emitted by the compiler - E0664, // this error code is no longer emitted by the compiler - E0665, // this error code is no longer emitted by the compiler - E0666, - E0667, - E0668, // this error code is no longer emitted by the compiler - E0669, // this error code is no longer emitted by the compiler - E0670, - E0671, // this error code is no longer emitted by the compiler - E0687, // this error code is no longer emitted by the compiler - E0688, // this error code is no longer emitted by the compiler - E0689, - E0690, - E0691, - E0692, - E0693, - E0695, - E0696, - E0697, - E0698, - E0699, - E0700, - E0701, - E0703, - E0704, - E0705, - E0706, - E0708, - E0710, - E0711, - E0712, - E0713, - E0714, - E0715, - E0716, - E0717, - E0718, - E0719, - E0720, - E0722, - E0724, - E0725, - E0726, - E0727, - E0728, - E0729, - E0730, - E0731, - E0732, - E0733, - E0734, - E0735, - E0736, - E0737, - E0739, - E0740, - E0741, - E0742, - E0743, - E0744, - E0745, - E0746, - E0747, - E0748, - E0749, - E0750, - E0751, - E0752, - E0753, - E0754, - E0755, - E0756, - E0757, - E0758, - E0759, // this error code is no longer emitted by the compiler - E0760, // this error code is no longer emitted by the compiler - E0761, - E0762, - E0763, - E0764, - E0765, - E0766, - E0767, - E0768, - E0769, - E0770, - E0771, - E0772, // this error code is no longer emitted by the compiler - E0773, - E0774, - E0775, - E0776, - E0777, - E0778, - E0779, - E0780, - E0781, - E0782, - E0783, - E0784, - E0785, - E0786, - E0787, - E0788, - E0789, - E0790, - E0791, - E0792, - E0793, - E0794 -}; - -// Custom hash function for ErrorCode, for older version of gcc -namespace std { - template <> - struct hash { - size_t operator() (const ErrorCode &error) const - { - return hash::type> () ( - static_cast::type> (error)); - } - }; -} - -// see https://github.com/Rust-GCC/gccrs/pull/2468 -#define XSTR(A) STR(A) -#define STR(A) #A -#define ERROR_CODE(NUM) NUM -#define TABLE_TO_MAP(NUM) { ErrorCode::ERROR_CODE(NUM), XSTR(ERROR_CODE(NUM)) } - -static std::unordered_map error_code_strings = { -TABLE_TO_MAP(E0001), -TABLE_TO_MAP(E0002), -TABLE_TO_MAP(E0004), -TABLE_TO_MAP(E0005), -TABLE_TO_MAP(E0007), -TABLE_TO_MAP(E0009), -TABLE_TO_MAP(E0010), -TABLE_TO_MAP(E0013), -TABLE_TO_MAP(E0014), -TABLE_TO_MAP(E0015), -TABLE_TO_MAP(E0023), -TABLE_TO_MAP(E0025), -TABLE_TO_MAP(E0026), -TABLE_TO_MAP(E0027), -TABLE_TO_MAP(E0029), -TABLE_TO_MAP(E0030), -TABLE_TO_MAP(E0033), -TABLE_TO_MAP(E0034), -TABLE_TO_MAP(E0038), -TABLE_TO_MAP(E0040), -TABLE_TO_MAP(E0044), -TABLE_TO_MAP(E0045), -TABLE_TO_MAP(E0046), -TABLE_TO_MAP(E0049), -TABLE_TO_MAP(E0050), -TABLE_TO_MAP(E0053), -TABLE_TO_MAP(E0054), -TABLE_TO_MAP(E0055), -TABLE_TO_MAP(E0057), -TABLE_TO_MAP(E0059), -TABLE_TO_MAP(E0060), -TABLE_TO_MAP(E0061), -TABLE_TO_MAP(E0062), -TABLE_TO_MAP(E0063), -TABLE_TO_MAP(E0067), -TABLE_TO_MAP(E0069), -TABLE_TO_MAP(E0070), -TABLE_TO_MAP(E0071), -TABLE_TO_MAP(E0072), -TABLE_TO_MAP(E0073), -TABLE_TO_MAP(E0074), -TABLE_TO_MAP(E0075), -TABLE_TO_MAP(E0076), -TABLE_TO_MAP(E0077), -TABLE_TO_MAP(E0080), -TABLE_TO_MAP(E0081), -TABLE_TO_MAP(E0084), -TABLE_TO_MAP(E0087), -TABLE_TO_MAP(E0088), -TABLE_TO_MAP(E0089), -TABLE_TO_MAP(E0090), -TABLE_TO_MAP(E0091), -TABLE_TO_MAP(E0092), -TABLE_TO_MAP(E0093), -TABLE_TO_MAP(E0094), -TABLE_TO_MAP(E0106), -TABLE_TO_MAP(E0107), -TABLE_TO_MAP(E0109), -TABLE_TO_MAP(E0110), -TABLE_TO_MAP(E0116), -TABLE_TO_MAP(E0117), -TABLE_TO_MAP(E0118), -TABLE_TO_MAP(E0119), -TABLE_TO_MAP(E0120), -TABLE_TO_MAP(E0121), -TABLE_TO_MAP(E0124), -TABLE_TO_MAP(E0128), -TABLE_TO_MAP(E0130), -TABLE_TO_MAP(E0131), -TABLE_TO_MAP(E0132), -TABLE_TO_MAP(E0133), -TABLE_TO_MAP(E0136), -TABLE_TO_MAP(E0137), -TABLE_TO_MAP(E0138), -TABLE_TO_MAP(E0139), -TABLE_TO_MAP(E0152), -TABLE_TO_MAP(E0154), -TABLE_TO_MAP(E0158), -TABLE_TO_MAP(E0161), -TABLE_TO_MAP(E0162), -TABLE_TO_MAP(E0164), -TABLE_TO_MAP(E0165), -TABLE_TO_MAP(E0170), -TABLE_TO_MAP(E0178), -TABLE_TO_MAP(E0183), -TABLE_TO_MAP(E0184), -TABLE_TO_MAP(E0185), -TABLE_TO_MAP(E0186), -TABLE_TO_MAP(E0191), -TABLE_TO_MAP(E0192), -TABLE_TO_MAP(E0193), -TABLE_TO_MAP(E0195), -TABLE_TO_MAP(E0197), -TABLE_TO_MAP(E0198), -TABLE_TO_MAP(E0199), -TABLE_TO_MAP(E0200), -TABLE_TO_MAP(E0201), -TABLE_TO_MAP(E0203), -TABLE_TO_MAP(E0204), -TABLE_TO_MAP(E0205), -TABLE_TO_MAP(E0206), -TABLE_TO_MAP(E0207), -TABLE_TO_MAP(E0208), -TABLE_TO_MAP(E0210), -TABLE_TO_MAP(E0211), -TABLE_TO_MAP(E0212), -TABLE_TO_MAP(E0214), -TABLE_TO_MAP(E0220), -TABLE_TO_MAP(E0221), -TABLE_TO_MAP(E0222), -TABLE_TO_MAP(E0223), -TABLE_TO_MAP(E0224), -TABLE_TO_MAP(E0225), -TABLE_TO_MAP(E0226), -TABLE_TO_MAP(E0227), -TABLE_TO_MAP(E0228), -TABLE_TO_MAP(E0229), -TABLE_TO_MAP(E0230), -TABLE_TO_MAP(E0231), -TABLE_TO_MAP(E0232), -TABLE_TO_MAP(E0243), -TABLE_TO_MAP(E0244), -TABLE_TO_MAP(E0251), -TABLE_TO_MAP(E0252), -TABLE_TO_MAP(E0253), -TABLE_TO_MAP(E0254), -TABLE_TO_MAP(E0255), -TABLE_TO_MAP(E0256), -TABLE_TO_MAP(E0259), -TABLE_TO_MAP(E0260), -TABLE_TO_MAP(E0261), -TABLE_TO_MAP(E0262), -TABLE_TO_MAP(E0263), -TABLE_TO_MAP(E0264), -TABLE_TO_MAP(E0267), -TABLE_TO_MAP(E0268), -TABLE_TO_MAP(E0271), -TABLE_TO_MAP(E0275), -TABLE_TO_MAP(E0276), -TABLE_TO_MAP(E0277), -TABLE_TO_MAP(E0281), -TABLE_TO_MAP(E0282), -TABLE_TO_MAP(E0283), -TABLE_TO_MAP(E0284), -TABLE_TO_MAP(E0297), -TABLE_TO_MAP(E0301), -TABLE_TO_MAP(E0302), -TABLE_TO_MAP(E0303), -TABLE_TO_MAP(E0307), -TABLE_TO_MAP(E0308), -TABLE_TO_MAP(E0309), -TABLE_TO_MAP(E0310), -TABLE_TO_MAP(E0311), -TABLE_TO_MAP(E0312), -TABLE_TO_MAP(E0316), -TABLE_TO_MAP(E0317), -TABLE_TO_MAP(E0320), -TABLE_TO_MAP(E0321), -TABLE_TO_MAP(E0322), -TABLE_TO_MAP(E0323), -TABLE_TO_MAP(E0324), -TABLE_TO_MAP(E0325), -TABLE_TO_MAP(E0326), -TABLE_TO_MAP(E0328), -TABLE_TO_MAP(E0329), -TABLE_TO_MAP(E0364), -TABLE_TO_MAP(E0365), -TABLE_TO_MAP(E0366), -TABLE_TO_MAP(E0367), -TABLE_TO_MAP(E0368), -TABLE_TO_MAP(E0369), -TABLE_TO_MAP(E0370), -TABLE_TO_MAP(E0371), -TABLE_TO_MAP(E0373), -TABLE_TO_MAP(E0374), -TABLE_TO_MAP(E0375), -TABLE_TO_MAP(E0376), -TABLE_TO_MAP(E0377), -TABLE_TO_MAP(E0378), -TABLE_TO_MAP(E0379), -TABLE_TO_MAP(E0380), -TABLE_TO_MAP(E0381), -TABLE_TO_MAP(E0382), -TABLE_TO_MAP(E0383), -TABLE_TO_MAP(E0384), -TABLE_TO_MAP(E0386), -TABLE_TO_MAP(E0387), -TABLE_TO_MAP(E0388), -TABLE_TO_MAP(E0389), -TABLE_TO_MAP(E0390), -TABLE_TO_MAP(E0391), -TABLE_TO_MAP(E0392), -TABLE_TO_MAP(E0393), -TABLE_TO_MAP(E0398), -TABLE_TO_MAP(E0399), -TABLE_TO_MAP(E0401), -TABLE_TO_MAP(E0403), -TABLE_TO_MAP(E0404), -TABLE_TO_MAP(E0405), -TABLE_TO_MAP(E0407), -TABLE_TO_MAP(E0408), -TABLE_TO_MAP(E0409), -TABLE_TO_MAP(E0411), -TABLE_TO_MAP(E0412), -TABLE_TO_MAP(E0415), -TABLE_TO_MAP(E0416), -TABLE_TO_MAP(E0422), -TABLE_TO_MAP(E0423), -TABLE_TO_MAP(E0424), -TABLE_TO_MAP(E0425), -TABLE_TO_MAP(E0426), -TABLE_TO_MAP(E0428), -TABLE_TO_MAP(E0429), -TABLE_TO_MAP(E0430), -TABLE_TO_MAP(E0431), -TABLE_TO_MAP(E0432), -TABLE_TO_MAP(E0433), -TABLE_TO_MAP(E0434), -TABLE_TO_MAP(E0435), -TABLE_TO_MAP(E0436), -TABLE_TO_MAP(E0437), -TABLE_TO_MAP(E0438), -TABLE_TO_MAP(E0439), -TABLE_TO_MAP(E0445), -TABLE_TO_MAP(E0446), -TABLE_TO_MAP(E0447), -TABLE_TO_MAP(E0448), -TABLE_TO_MAP(E0449), -TABLE_TO_MAP(E0451), -TABLE_TO_MAP(E0452), -TABLE_TO_MAP(E0453), -TABLE_TO_MAP(E0454), -TABLE_TO_MAP(E0455), -TABLE_TO_MAP(E0457), -TABLE_TO_MAP(E0458), -TABLE_TO_MAP(E0459), -TABLE_TO_MAP(E0460), -TABLE_TO_MAP(E0461), -TABLE_TO_MAP(E0462), -TABLE_TO_MAP(E0463), -TABLE_TO_MAP(E0464), -TABLE_TO_MAP(E0466), -TABLE_TO_MAP(E0468), -TABLE_TO_MAP(E0469), -TABLE_TO_MAP(E0472), -TABLE_TO_MAP(E0476), -TABLE_TO_MAP(E0477), -TABLE_TO_MAP(E0478), -TABLE_TO_MAP(E0482), -TABLE_TO_MAP(E0491), -TABLE_TO_MAP(E0492), -TABLE_TO_MAP(E0493), -TABLE_TO_MAP(E0495), -TABLE_TO_MAP(E0496), -TABLE_TO_MAP(E0497), -TABLE_TO_MAP(E0498), -TABLE_TO_MAP(E0499), -TABLE_TO_MAP(E0500), -TABLE_TO_MAP(E0501), -TABLE_TO_MAP(E0502), -TABLE_TO_MAP(E0503), -TABLE_TO_MAP(E0504), -TABLE_TO_MAP(E0505), -TABLE_TO_MAP(E0506), -TABLE_TO_MAP(E0507), -TABLE_TO_MAP(E0508), -TABLE_TO_MAP(E0509), -TABLE_TO_MAP(E0510), -TABLE_TO_MAP(E0511), -TABLE_TO_MAP(E0512), -TABLE_TO_MAP(E0514), -TABLE_TO_MAP(E0515), -TABLE_TO_MAP(E0516), -TABLE_TO_MAP(E0517), -TABLE_TO_MAP(E0518), -TABLE_TO_MAP(E0519), -TABLE_TO_MAP(E0520), -TABLE_TO_MAP(E0521), -TABLE_TO_MAP(E0522), -TABLE_TO_MAP(E0523), -TABLE_TO_MAP(E0524), -TABLE_TO_MAP(E0525), -TABLE_TO_MAP(E0527), -TABLE_TO_MAP(E0528), -TABLE_TO_MAP(E0529), -TABLE_TO_MAP(E0530), -TABLE_TO_MAP(E0531), -TABLE_TO_MAP(E0532), -TABLE_TO_MAP(E0533), -TABLE_TO_MAP(E0534), -TABLE_TO_MAP(E0535), -TABLE_TO_MAP(E0536), -TABLE_TO_MAP(E0537), -TABLE_TO_MAP(E0538), -TABLE_TO_MAP(E0539), -TABLE_TO_MAP(E0541), -TABLE_TO_MAP(E0542), -TABLE_TO_MAP(E0543), -TABLE_TO_MAP(E0544), -TABLE_TO_MAP(E0545), -TABLE_TO_MAP(E0546), -TABLE_TO_MAP(E0547), -TABLE_TO_MAP(E0549), -TABLE_TO_MAP(E0550), -TABLE_TO_MAP(E0551), -TABLE_TO_MAP(E0552), -TABLE_TO_MAP(E0554), -TABLE_TO_MAP(E0556), -TABLE_TO_MAP(E0557), -TABLE_TO_MAP(E0559), -TABLE_TO_MAP(E0560), -TABLE_TO_MAP(E0561), -TABLE_TO_MAP(E0562), -TABLE_TO_MAP(E0565), -TABLE_TO_MAP(E0566), -TABLE_TO_MAP(E0567), -TABLE_TO_MAP(E0568), -TABLE_TO_MAP(E0569), -TABLE_TO_MAP(E0570), -TABLE_TO_MAP(E0571), -TABLE_TO_MAP(E0572), -TABLE_TO_MAP(E0573), -TABLE_TO_MAP(E0574), -TABLE_TO_MAP(E0575), -TABLE_TO_MAP(E0576), -TABLE_TO_MAP(E0577), -TABLE_TO_MAP(E0578), -TABLE_TO_MAP(E0579), -TABLE_TO_MAP(E0580), -TABLE_TO_MAP(E0581), -TABLE_TO_MAP(E0582), -TABLE_TO_MAP(E0583), -TABLE_TO_MAP(E0584), -TABLE_TO_MAP(E0585), -TABLE_TO_MAP(E0586), -TABLE_TO_MAP(E0587), -TABLE_TO_MAP(E0588), -TABLE_TO_MAP(E0589), -TABLE_TO_MAP(E0590), -TABLE_TO_MAP(E0591), -TABLE_TO_MAP(E0592), -TABLE_TO_MAP(E0593), -TABLE_TO_MAP(E0594), -TABLE_TO_MAP(E0595), -TABLE_TO_MAP(E0596), -TABLE_TO_MAP(E0597), -TABLE_TO_MAP(E0599), -TABLE_TO_MAP(E0600), -TABLE_TO_MAP(E0601), -TABLE_TO_MAP(E0602), -TABLE_TO_MAP(E0603), -TABLE_TO_MAP(E0604), -TABLE_TO_MAP(E0605), -TABLE_TO_MAP(E0606), -TABLE_TO_MAP(E0607), -TABLE_TO_MAP(E0608), -TABLE_TO_MAP(E0609), -TABLE_TO_MAP(E0610), -TABLE_TO_MAP(E0614), -TABLE_TO_MAP(E0615), -TABLE_TO_MAP(E0616), -TABLE_TO_MAP(E0617), -TABLE_TO_MAP(E0618), -TABLE_TO_MAP(E0619), -TABLE_TO_MAP(E0620), -TABLE_TO_MAP(E0621), -TABLE_TO_MAP(E0622), -TABLE_TO_MAP(E0623), -TABLE_TO_MAP(E0624), -TABLE_TO_MAP(E0625), -TABLE_TO_MAP(E0626), -TABLE_TO_MAP(E0627), -TABLE_TO_MAP(E0628), -TABLE_TO_MAP(E0631), -TABLE_TO_MAP(E0632), -TABLE_TO_MAP(E0633), -TABLE_TO_MAP(E0634), -TABLE_TO_MAP(E0635), -TABLE_TO_MAP(E0636), -TABLE_TO_MAP(E0637), -TABLE_TO_MAP(E0638), -TABLE_TO_MAP(E0639), -TABLE_TO_MAP(E0640), -TABLE_TO_MAP(E0641), -TABLE_TO_MAP(E0642), -TABLE_TO_MAP(E0643), -TABLE_TO_MAP(E0644), -TABLE_TO_MAP(E0646), -TABLE_TO_MAP(E0647), -TABLE_TO_MAP(E0648), -TABLE_TO_MAP(E0657), -TABLE_TO_MAP(E0658), -TABLE_TO_MAP(E0659), -TABLE_TO_MAP(E0660), -TABLE_TO_MAP(E0661), -TABLE_TO_MAP(E0662), -TABLE_TO_MAP(E0663), -TABLE_TO_MAP(E0664), -TABLE_TO_MAP(E0665), -TABLE_TO_MAP(E0666), -TABLE_TO_MAP(E0667), -TABLE_TO_MAP(E0668), -TABLE_TO_MAP(E0669), -TABLE_TO_MAP(E0670), -TABLE_TO_MAP(E0671), -TABLE_TO_MAP(E0687), -TABLE_TO_MAP(E0688), -TABLE_TO_MAP(E0689), -TABLE_TO_MAP(E0690), -TABLE_TO_MAP(E0691), -TABLE_TO_MAP(E0692), -TABLE_TO_MAP(E0693), -TABLE_TO_MAP(E0695), -TABLE_TO_MAP(E0696), -TABLE_TO_MAP(E0697), -TABLE_TO_MAP(E0698), -TABLE_TO_MAP(E0699), -TABLE_TO_MAP(E0700), -TABLE_TO_MAP(E0701), -TABLE_TO_MAP(E0703), -TABLE_TO_MAP(E0704), -TABLE_TO_MAP(E0705), -TABLE_TO_MAP(E0706), -TABLE_TO_MAP(E0708), -TABLE_TO_MAP(E0710), -TABLE_TO_MAP(E0711), -TABLE_TO_MAP(E0712), -TABLE_TO_MAP(E0713), -TABLE_TO_MAP(E0714), -TABLE_TO_MAP(E0715), -TABLE_TO_MAP(E0716), -TABLE_TO_MAP(E0717), -TABLE_TO_MAP(E0718), -TABLE_TO_MAP(E0719), -TABLE_TO_MAP(E0720), -TABLE_TO_MAP(E0722), -TABLE_TO_MAP(E0724), -TABLE_TO_MAP(E0725), -TABLE_TO_MAP(E0726), -TABLE_TO_MAP(E0727), -TABLE_TO_MAP(E0728), -TABLE_TO_MAP(E0729), -TABLE_TO_MAP(E0730), -TABLE_TO_MAP(E0731), -TABLE_TO_MAP(E0732), -TABLE_TO_MAP(E0733), -TABLE_TO_MAP(E0734), -TABLE_TO_MAP(E0735), -TABLE_TO_MAP(E0736), -TABLE_TO_MAP(E0737), -TABLE_TO_MAP(E0739), -TABLE_TO_MAP(E0740), -TABLE_TO_MAP(E0741), -TABLE_TO_MAP(E0742), -TABLE_TO_MAP(E0743), -TABLE_TO_MAP(E0744), -TABLE_TO_MAP(E0745), -TABLE_TO_MAP(E0746), -TABLE_TO_MAP(E0747), -TABLE_TO_MAP(E0748), -TABLE_TO_MAP(E0749), -TABLE_TO_MAP(E0750), -TABLE_TO_MAP(E0751), -TABLE_TO_MAP(E0752), -TABLE_TO_MAP(E0753), -TABLE_TO_MAP(E0754), -TABLE_TO_MAP(E0755), -TABLE_TO_MAP(E0756), -TABLE_TO_MAP(E0757), -TABLE_TO_MAP(E0758), -TABLE_TO_MAP(E0759), -TABLE_TO_MAP(E0760), -TABLE_TO_MAP(E0761), -TABLE_TO_MAP(E0762), -TABLE_TO_MAP(E0763), -TABLE_TO_MAP(E0764), -TABLE_TO_MAP(E0765), -TABLE_TO_MAP(E0766), -TABLE_TO_MAP(E0767), -TABLE_TO_MAP(E0768), -TABLE_TO_MAP(E0769), -TABLE_TO_MAP(E0770), -TABLE_TO_MAP(E0771), -TABLE_TO_MAP(E0772), -TABLE_TO_MAP(E0773), -TABLE_TO_MAP(E0774), -TABLE_TO_MAP(E0775), -TABLE_TO_MAP(E0776), -TABLE_TO_MAP(E0777), -TABLE_TO_MAP(E0778), -TABLE_TO_MAP(E0779), -TABLE_TO_MAP(E0780), -TABLE_TO_MAP(E0781), -TABLE_TO_MAP(E0782), -TABLE_TO_MAP(E0783), -TABLE_TO_MAP(E0784), -TABLE_TO_MAP(E0785), -TABLE_TO_MAP(E0786), -TABLE_TO_MAP(E0787), -TABLE_TO_MAP(E0788), -TABLE_TO_MAP(E0789), -TABLE_TO_MAP(E0790), -TABLE_TO_MAP(E0791), -TABLE_TO_MAP(E0792), -TABLE_TO_MAP(E0793), -TABLE_TO_MAP(E0794), + +// We want E0005 to be mapped to the value `5` - this way, we can easily format +// it in `make_description`. We also want to keep the value "5" only once when +// defining the error code in rust_error_codes.def, so not have ERROR(E0005, 5) +// as that is error prone. If we just use `0005` as the discriminant for the +// `E0005` enum variant, then we are actually creating octal values (!) as `0` +// is the C/C++ octal prefix. So this does not work for `E0009` for example, +// since 0009 is not a valid octal literal. +// We can circumvent this by doing a little bit of constant folding in the +// discriminant expression. So for ERROR(E0009), this macro expands to the +// following variant: +// +// E0009 = (10009 - 10000) +// +// which gets folded to the result of the substraction... 9. A valid decimal +// literal which corresponds to E0009. +#define ERROR(N) E##N = (1##N - 10000) +enum class ErrorCode : unsigned int +{ +#include "rust_error_codes.def" }; +#undef ERROR +// clang-format off extern void rust_internal_error_at (const location_t, const char *fmt, ...) RUST_ATTRIBUTE_GCC_DIAG (2, 3) diff --git a/gcc/rust/rust_error_codes.def b/gcc/rust/rust_error_codes.def new file mode 100644 index 00000000000..cb9856d72d4 --- /dev/null +++ b/gcc/rust/rust_error_codes.def @@ -0,0 +1,506 @@ +ERROR(0001), // this error code is no longer emitted by the compiler +ERROR(0002), // this error code is no longer emitted by the compiler +ERROR(0004), +ERROR(0005), +ERROR(0007), // this error code is no longer emitted by the compiler +ERROR(0009), // this error code is no longer emitted by the compiler +ERROR(0010), +ERROR(0013), +ERROR(0014), // this error code is no longer emitted by the compiler +ERROR(0015), +ERROR(0023), +ERROR(0025), +ERROR(0026), +ERROR(0027), +ERROR(0029), +ERROR(0030), +ERROR(0033), +ERROR(0034), +ERROR(0038), +ERROR(0040), +ERROR(0044), +ERROR(0045), +ERROR(0046), +ERROR(0049), +ERROR(0050), +ERROR(0053), +ERROR(0054), +ERROR(0055), +ERROR(0057), +ERROR(0059), +ERROR(0060), +ERROR(0061), +ERROR(0062), +ERROR(0063), +ERROR(0067), +ERROR(0069), +ERROR(0070), +ERROR(0071), +ERROR(0072), +ERROR(0073), // this error code is no longer emitted by the compiler +ERROR(0074), // this error code is no longer emitted by the compiler +ERROR(0075), +ERROR(0076), +ERROR(0077), +ERROR(0080), +ERROR(0081), +ERROR(0084), +ERROR(0087), // this error code is no longer emitted by the compiler +ERROR(0088), // this error code is no longer emitted by the compiler +ERROR(0089), // this error code is no longer emitted by the compiler +ERROR(0090), // this error code is no longer emitted by the compiler +ERROR(0091), +ERROR(0092), +ERROR(0093), +ERROR(0094), +ERROR(0106), +ERROR(0107), +ERROR(0109), +ERROR(0110), // this error code is no longer emitted by the compiler +ERROR(0116), +ERROR(0117), +ERROR(0118), +ERROR(0119), +ERROR(0120), +ERROR(0121), +ERROR(0124), +ERROR(0128), +ERROR(0130), +ERROR(0131), +ERROR(0132), +ERROR(0133), +ERROR(0136), // this error code is no longer emitted by the compiler +ERROR(0137), // this error code is no longer emitted by the compiler +ERROR(0138), +ERROR(0139), // this error code is no longer emitted by the compiler +ERROR(0152), +ERROR(0154), // this error code is no longer emitted by the compiler +ERROR(0158), +ERROR(0161), +ERROR(0162), // this error code is no longer emitted by the compiler +ERROR(0164), +ERROR(0165), // this error code is no longer emitted by the compiler +ERROR(0170), +ERROR(0178), +ERROR(0183), +ERROR(0184), +ERROR(0185), +ERROR(0186), +ERROR(0191), +ERROR(0192), // this error code is no longer emitted by the compiler +ERROR(0193), // this error code is no longer emitted by the compiler +ERROR(0195), +ERROR(0197), +ERROR(0198), +ERROR(0199), +ERROR(0200), +ERROR(0201), +ERROR(0203), +ERROR(0204), +ERROR(0205), // this error code is no longer emitted by the compiler +ERROR(0206), +ERROR(0207), +ERROR(0208), // this error code is no longer emitted by the compiler +ERROR(0210), +ERROR(0211), // this error code is no longer emitted by the compiler +ERROR(0212), +ERROR(0214), +ERROR(0220), +ERROR(0221), +ERROR(0222), +ERROR(0223), +ERROR(0224), +ERROR(0225), +ERROR(0226), +ERROR(0227), +ERROR(0228), +ERROR(0229), +ERROR(0230), +ERROR(0231), +ERROR(0232), +ERROR(0243), // this error code is no longer emitted by the compiler +ERROR(0244), // this error code is no longer emitted by the compiler +ERROR(0251), // this error code is no longer emitted by the compiler +ERROR(0252), +ERROR(0253), +ERROR(0254), +ERROR(0255), +ERROR(0256), // this error code is no longer emitted by the compiler +ERROR(0259), +ERROR(0260), +ERROR(0261), +ERROR(0262), +ERROR(0263), // this error code is no longer emitted by the compiler +ERROR(0264), +ERROR(0267), +ERROR(0268), +ERROR(0271), +ERROR(0275), +ERROR(0276), +ERROR(0277), +ERROR(0281), // this error code is no longer emitted by the compiler +ERROR(0282), +ERROR(0283), +ERROR(0284), +ERROR(0297), // this error code is no longer emitted by the compiler +ERROR(0301), // this error code is no longer emitted by the compiler +ERROR(0302), // this error code is no longer emitted by the compiler +ERROR(0303), // this error code is no longer emitted by the compiler +ERROR(0307), +ERROR(0308), +ERROR(0309), +ERROR(0310), +ERROR(0311), +ERROR(0312), // this error code is no longer emitted by the compiler +ERROR(0316), +ERROR(0317), +ERROR(0320), +ERROR(0321), +ERROR(0322), +ERROR(0323), +ERROR(0324), +ERROR(0325), +ERROR(0326), +ERROR(0328), +ERROR(0329), // this error code is no longer emitted by the compiler +ERROR(0364), +ERROR(0365), +ERROR(0366), +ERROR(0367), +ERROR(0368), +ERROR(0369), +ERROR(0370), +ERROR(0371), +ERROR(0373), +ERROR(0374), +ERROR(0375), +ERROR(0376), +ERROR(0377), +ERROR(0378), +ERROR(0379), +ERROR(0380), +ERROR(0381), +ERROR(0382), +ERROR(0383), // this error code is no longer emitted by the compiler +ERROR(0384), +ERROR(0386), // this error code is no longer emitted by the compiler +ERROR(0387), // this error code is no longer emitted by the compiler +ERROR(0388), // this error code is no longer emitted by the compiler +ERROR(0389), // this error code is no longer emitted by the compiler +ERROR(0390), +ERROR(0391), +ERROR(0392), +ERROR(0393), +ERROR(0398), // this error code is no longer emitted by the compiler +ERROR(0399), +ERROR(0401), +ERROR(0403), +ERROR(0404), +ERROR(0405), +ERROR(0407), +ERROR(0408), +ERROR(0409), +ERROR(0411), +ERROR(0412), +ERROR(0415), +ERROR(0416), +ERROR(0422), +ERROR(0423), +ERROR(0424), +ERROR(0425), +ERROR(0426), +ERROR(0428), +ERROR(0429), +ERROR(0430), +ERROR(0431), +ERROR(0432), +ERROR(0433), +ERROR(0434), +ERROR(0435), +ERROR(0436), +ERROR(0437), +ERROR(0438), +ERROR(0439), // this error code is no longer emitted by the compiler +ERROR(0445), +ERROR(0446), +ERROR(0447), // this error code is no longer emitted by the compiler +ERROR(0448), // this error code is no longer emitted by the compiler +ERROR(0449), +ERROR(0451), +ERROR(0452), +ERROR(0453), +ERROR(0454), +ERROR(0455), +ERROR(0457), +ERROR(0458), +ERROR(0459), +ERROR(0460), +ERROR(0461), +ERROR(0462), +ERROR(0463), +ERROR(0464), +ERROR(0466), +ERROR(0468), +ERROR(0469), +ERROR(0472), +ERROR(0476), +ERROR(0477), // this error code is no longer emitted by the compiler +ERROR(0478), +ERROR(0482), // this error code is no longer emitted by the compiler +ERROR(0491), +ERROR(0492), +ERROR(0493), +ERROR(0495), // this error code is no longer emitted by the compiler +ERROR(0496), +ERROR(0497), // this error code is no longer emitted by the compiler +ERROR(0498), +ERROR(0499), +ERROR(0500), +ERROR(0501), +ERROR(0502), +ERROR(0503), +ERROR(0504), // this error code is no longer emitted by the compiler +ERROR(0505), +ERROR(0506), +ERROR(0507), +ERROR(0508), +ERROR(0509), +ERROR(0510), +ERROR(0511), +ERROR(0512), +ERROR(0514), +ERROR(0515), +ERROR(0516), +ERROR(0517), +ERROR(0518), +ERROR(0519), +ERROR(0520), +ERROR(0521), +ERROR(0522), +ERROR(0523), // this error code is no longer emitted by the compiler +ERROR(0524), +ERROR(0525), +ERROR(0527), +ERROR(0528), +ERROR(0529), +ERROR(0530), +ERROR(0531), +ERROR(0532), +ERROR(0533), +ERROR(0534), +ERROR(0535), +ERROR(0536), +ERROR(0537), +ERROR(0538), +ERROR(0539), +ERROR(0541), +ERROR(0542), +ERROR(0543), +ERROR(0544), +ERROR(0545), +ERROR(0546), +ERROR(0547), +ERROR(0549), +ERROR(0550), +ERROR(0551), +ERROR(0552), +ERROR(0554), +ERROR(0556), +ERROR(0557), +ERROR(0559), +ERROR(0560), +ERROR(0561), +ERROR(0562), +ERROR(0565), +ERROR(0566), +ERROR(0567), +ERROR(0568), +ERROR(0569), +ERROR(0570), +ERROR(0571), +ERROR(0572), +ERROR(0573), +ERROR(0574), +ERROR(0575), +ERROR(0576), +ERROR(0577), +ERROR(0578), +ERROR(0579), +ERROR(0580), +ERROR(0581), +ERROR(0582), +ERROR(0583), +ERROR(0584), +ERROR(0585), +ERROR(0586), +ERROR(0587), +ERROR(0588), +ERROR(0589), +ERROR(0590), +ERROR(0591), +ERROR(0592), +ERROR(0593), +ERROR(0594), +ERROR(0595), // this error code is no longer emitted by the compiler +ERROR(0596), +ERROR(0597), +ERROR(0599), +ERROR(0600), +ERROR(0601), +ERROR(0602), +ERROR(0603), +ERROR(0604), +ERROR(0605), +ERROR(0606), +ERROR(0607), +ERROR(0608), +ERROR(0609), +ERROR(0610), +ERROR(0614), +ERROR(0615), +ERROR(0616), +ERROR(0617), +ERROR(0618), +ERROR(0619), // this error code is no longer emitted by the compiler +ERROR(0620), +ERROR(0621), +ERROR(0622), +ERROR(0623), +ERROR(0624), +ERROR(0625), +ERROR(0626), +ERROR(0627), +ERROR(0628), +ERROR(0631), +ERROR(0632), // this error code is no longer emitted by the compiler +ERROR(0633), // this error code is no longer emitted by the compiler +ERROR(0634), +ERROR(0635), +ERROR(0636), +ERROR(0637), +ERROR(0638), +ERROR(0639), +ERROR(0640), +ERROR(0641), +ERROR(0642), +ERROR(0643), +ERROR(0644), +ERROR(0646), +ERROR(0647), +ERROR(0648), +ERROR(0657), +ERROR(0658), +ERROR(0659), +ERROR(0660), // this error code is no longer emitted by the compiler +ERROR(0661), // this error code is no longer emitted by the compiler +ERROR(0662), // this error code is no longer emitted by the compiler +ERROR(0663), // this error code is no longer emitted by the compiler +ERROR(0664), // this error code is no longer emitted by the compiler +ERROR(0665), // this error code is no longer emitted by the compiler +ERROR(0666), +ERROR(0667), +ERROR(0668), // this error code is no longer emitted by the compiler +ERROR(0669), // this error code is no longer emitted by the compiler +ERROR(0670), +ERROR(0671), // this error code is no longer emitted by the compiler +ERROR(0687), // this error code is no longer emitted by the compiler +ERROR(0688), // this error code is no longer emitted by the compiler +ERROR(0689), +ERROR(0690), +ERROR(0691), +ERROR(0692), +ERROR(0693), +ERROR(0695), +ERROR(0696), +ERROR(0697), +ERROR(0698), +ERROR(0699), +ERROR(0700), +ERROR(0701), +ERROR(0703), +ERROR(0704), +ERROR(0705), +ERROR(0706), +ERROR(0708), +ERROR(0710), +ERROR(0711), +ERROR(0712), +ERROR(0713), +ERROR(0714), +ERROR(0715), +ERROR(0716), +ERROR(0717), +ERROR(0718), +ERROR(0719), +ERROR(0720), +ERROR(0722), +ERROR(0724), +ERROR(0725), +ERROR(0726), +ERROR(0727), +ERROR(0728), +ERROR(0729), +ERROR(0730), +ERROR(0731), +ERROR(0732), +ERROR(0733), +ERROR(0734), +ERROR(0735), +ERROR(0736), +ERROR(0737), +ERROR(0739), +ERROR(0740), +ERROR(0741), +ERROR(0742), +ERROR(0743), +ERROR(0744), +ERROR(0745), +ERROR(0746), +ERROR(0747), +ERROR(0748), +ERROR(0749), +ERROR(0750), +ERROR(0751), +ERROR(0752), +ERROR(0753), +ERROR(0754), +ERROR(0755), +ERROR(0756), +ERROR(0757), +ERROR(0758), +ERROR(0759), // this error code is no longer emitted by the compiler +ERROR(0760), // this error code is no longer emitted by the compiler +ERROR(0761), +ERROR(0762), +ERROR(0763), +ERROR(0764), +ERROR(0765), +ERROR(0766), +ERROR(0767), +ERROR(0768), +ERROR(0769), +ERROR(0770), +ERROR(0771), +ERROR(0772), // this error code is no longer emitted by the compiler +ERROR(0773), +ERROR(0774), +ERROR(0775), +ERROR(0776), +ERROR(0777), +ERROR(0778), +ERROR(0779), +ERROR(0780), +ERROR(0781), +ERROR(0782), +ERROR(0783), +ERROR(0784), +ERROR(0785), +ERROR(0786), +ERROR(0787), +ERROR(0788), +ERROR(0789), +ERROR(0790), +ERROR(0791), +ERROR(0792), +ERROR(0793), +ERROR(0794) \ No newline at end of file