You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix @structcloses#426, and lay more groundwork for generative metafunctions
Fix `@struct` to generate a type that's actually usable as a struct, by providing a metafunction a way to disable all member function generation
Make member initialization diagnostics clearer and more actionable, with better source location attribution
Lay more groundwork for generative metafunctions like `enum` and `flag_enum` that replace the entire type's contents, including to move more semantic checks to `sema.h` where they belong and will run later
Copy file name to clipboardExpand all lines: source/cppfront.cpp
+40-17Lines changed: 40 additions & 17 deletions
Original file line number
Diff line number
Diff line change
@@ -4488,7 +4488,8 @@ class cppfront
4488
4488
4489
4489
// We'll use this common guidance in several errors,
4490
4490
// so write it once to keep the guidance consistent
4491
-
auto error_msg = "an operator= body must start with a series of 'member = value;' initialization statements for each of the type-scope objects in the same order they are declared";
auto error_msg = "an operator= body must start with a series of 'member = value;' initialization statements for each of the type-scope objects in the same order they are declared, or the member must have a default initializer (in type '" + n.parent_declaration->name()->to_string(true) + "')";
4492
4493
4493
4494
// If this constructor's type has data members, handle their initialization
4494
4495
// - objects is the list of this type's declarations
"in operator=, expected '" + object_name + " = ...' initialization statement (because type scope object '" + object_name + "' does not have a default initializer)"
4623
+
);
4624
+
errors.emplace_back(
4625
+
(*object)->position(),
4626
+
"see declaration for '" + object_name + "' here"
4627
+
);
4628
+
errors.emplace_back(
4629
+
stmt_pos,
4630
+
error_msg
4619
4631
);
4620
4632
return;
4621
4633
}
@@ -4731,7 +4743,15 @@ class cppfront
4731
4743
{
4732
4744
errors.emplace_back(
4733
4745
(*object)->position(),
4734
-
canonize_object_name(*object) + " was not initialized - " + error_msg
4746
+
canonize_object_name(*object) + " was not initialized - did you forget to write a default initializer, or assign to it in the operator= body?"
4747
+
);
4748
+
errors.emplace_back(
4749
+
(*object)->position(),
4750
+
"see declaration for '" + canonize_object_name(*object) + "' here"
0 commit comments