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
Require that a type's implementation may not declare a name that is the same as (i.e., shadows) a type scope name - for example, a type scope function's local variable may not have the same as one of the type's members"
Also allow all data members to use their declared default initializers - removed spurious error check
auto guard = finally([&]{ current_declaration.pop_back(); });
3658
+
// In a type scope function, disallow declaring a name that is
3659
+
// the same as (i.e., shadows) a type scope name... this is a
3660
+
// convenient place to check because we have the decls stack
3661
+
if (
3662
+
n.has_name() // this is a named declaration
3663
+
&& !n.parent_is_type() // where the type isn't the direct parent
3664
+
&& is_name_declared_in_current_type_scope(*n.name()) // and it shadows a name
3665
+
&& !emit_constructor_as_assignment // (don't emit the error twice if this is the
3666
+
) // second time we're 're handling this function)
3667
+
{
3668
+
errors.emplace_back(
3669
+
n.position(),
3670
+
"a type's implementation may not declare a name that is the same as (i.e., shadows) a type scope name - for example, a type scope function's local variable may not have the same as one of the type's members"
3671
+
);
3672
+
return;
3673
+
}
3674
+
3675
+
current_declarations.push_back(&n);
3676
+
auto guard = finally([&]{ current_declarations.pop_back(); });
3617
3677
3618
3678
// If this is a function that has multiple return values,
3619
3679
// first we need to emit the struct that contains the returns
@@ -3863,13 +3923,6 @@ class cppfront
3863
3923
{
3864
3924
assert((*object)->has_name());
3865
3925
3866
-
// The ctor body can't have other statements until it
0 commit comments