Finished semantic analysis of anonymous unions in C++.
Duplicate-member checking within classes is still a little messy, and
anonymous unions are still completely broken in C. We'll need to unify
the handling of fields in C and C++ to make this code applicable in
both languages.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61878 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp
index 19582c0..c5e5aa2 100644
--- a/lib/Sema/SemaDeclCXX.cpp
+++ b/lib/Sema/SemaDeclCXX.cpp
@@ -427,9 +427,12 @@
// class itself; this is known as the injected-class-name. For
// purposes of access checking, the injected-class-name is treated
// as if it were a public member name.
- PushOnScopeChains(CXXRecordDecl::Create(Context, Dcl->getTagKind(),
- CurContext, Dcl->getLocation(),
- Dcl->getIdentifier(), Dcl), S);
+ RecordDecl *InjectedClassName
+ = CXXRecordDecl::Create(Context, Dcl->getTagKind(),
+ CurContext, Dcl->getLocation(),
+ Dcl->getIdentifier(), Dcl);
+ InjectedClassName->setImplicit();
+ PushOnScopeChains(InjectedClassName, S);
}
}
@@ -789,6 +792,7 @@
/*isInline=*/true,
/*isImplicitlyDeclared=*/true);
DefaultCon->setAccess(AS_public);
+ DefaultCon->setImplicit();
ClassDecl->addDecl(Context, DefaultCon);
// Notify the class that we've added a constructor.
@@ -860,6 +864,7 @@
/*isInline=*/true,
/*isImplicitlyDeclared=*/true);
CopyConstructor->setAccess(AS_public);
+ CopyConstructor->setImplicit();
// Add the parameter to the constructor.
ParmVarDecl *FromParam = ParmVarDecl::Create(Context, CopyConstructor,
@@ -936,6 +941,7 @@
false, 0),
/*isStatic=*/false, /*isInline=*/true, 0);
CopyAssignment->setAccess(AS_public);
+ CopyAssignment->setImplicit();
// Add the parameter to the operator.
ParmVarDecl *FromParam = ParmVarDecl::Create(Context, CopyAssignment,
@@ -964,6 +970,7 @@
/*isInline=*/true,
/*isImplicitlyDeclared=*/true);
Destructor->setAccess(AS_public);
+ Destructor->setImplicit();
ClassDecl->addDecl(Context, Destructor);
}
}