On 11/22/23 05:00, Jakub Jelinek wrote:
On Tue, Nov 21, 2023 at 10:51:36PM -0500, Jason Merrill wrote:
Actually, let's go back to the previous message, but change the tf_nones
above to 'complain' so that we see those errors and then this explanation.
Likewise with the conversion checks later in the function.

So like this?
Besides what you asked for I've separated the diagnostics for when size
member isn't found in lookup vs. when data isn't found, because it looked
weird to get 2 same errors e.g. in the udlit-error1.C case.

+      message_sz
+       = finish_class_member_access_expr (message,
+                                          get_identifier ("size"),
+                                          false, complain);
+      if (message_sz == error_mark_node)
+       {
+         error_at (location, "%<static_assert%> message must be a string "
+                             "literal or object with %<size%> and "
+                             "%<data%> members");
+         return;
+       }
+      message_data
+       = finish_class_member_access_expr (message,
+                                          get_identifier ("data"),
+                                          false, complain);
+      if (message_data == error_mark_node)
+       {
+         error_at (location, "%<static_assert%> message must be a string "
+                             "literal or object with %<size%> and "
+                             "%<data%> members");
+         return;
+       }

I agree it's weird to get two of the same error, but maybe instead of duplicating the error, we could look up data only if size succeeded, and then error once if either failed?

OK with that change.

Jason

Reply via email to