]> granicus.if.org Git - clang/commitdiff
Revert r130912 in order to approach defaulted functions from the other
authorSean Hunt <scshunt@csclub.uwaterloo.ca>
Fri, 6 May 2011 00:11:07 +0000 (00:11 +0000)
committerSean Hunt <scshunt@csclub.uwaterloo.ca>
Fri, 6 May 2011 00:11:07 +0000 (00:11 +0000)
direction and not introduce things in the wrong place three different
times.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130968 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/DeclCXX.h
include/clang/Basic/DiagnosticCommonKinds.td
include/clang/Basic/DiagnosticParseKinds.td
include/clang/Sema/Sema.h
lib/AST/ASTImporter.cpp
lib/AST/DeclCXX.cpp
lib/Parse/ParseDecl.cpp
lib/Parse/ParseDeclCXX.cpp
lib/Sema/SemaDecl.cpp
lib/Sema/SemaDeclCXX.cpp
lib/Sema/SemaTemplateInstantiateDecl.cpp

index f5026f5c4b4966c3935f6b1966cc154514cd9012..88f473eb48b2207b4034dd53b751ab310d34dc39 100644 (file)
@@ -1501,9 +1501,6 @@ class CXXConstructorDecl : public CXXMethodDecl {
   /// @c !Implicit && ImplicitlyDefined.
   bool ImplicitlyDefined : 1;
 
-  /// IsDefaulted - Whether this constructor was explicitly defaulted
-  bool ExplicitlyDefaulted : 1;
-
   /// Support for base and member initializers.
   /// CtorInitializers - The arguments used to initialize the base
   /// or member.
@@ -1514,13 +1511,11 @@ class CXXConstructorDecl : public CXXMethodDecl {
                      const DeclarationNameInfo &NameInfo,
                      QualType T, TypeSourceInfo *TInfo,
                      bool isExplicitSpecified, bool isInline, 
-                     bool isImplicitlyDeclared, bool isExplicitlyDefaulted)
+                     bool isImplicitlyDeclared)
     : CXXMethodDecl(CXXConstructor, RD, StartLoc, NameInfo, T, TInfo, false,
                     SC_None, isInline, SourceLocation()),
       IsExplicitSpecified(isExplicitSpecified), ImplicitlyDefined(false),
-      ExplicitlyDefaulted(isExplicitlyDefaulted),
-      CtorInitializers(0), NumCtorInitializers(0)
-  {
+      CtorInitializers(0), NumCtorInitializers(0) {
     setImplicit(isImplicitlyDeclared);
   }
 
@@ -1531,8 +1526,7 @@ public:
                                     const DeclarationNameInfo &NameInfo,
                                     QualType T, TypeSourceInfo *TInfo,
                                     bool isExplicit,
-                                    bool isInline, bool isImplicitlyDeclared,
-                                    bool isExplicitlyDefaulted);
+                                    bool isInline, bool isImplicitlyDeclared);
 
   /// isExplicitSpecified - Whether this constructor declaration has the
   /// 'explicit' keyword specified.
@@ -1564,28 +1558,6 @@ public:
     ImplicitlyDefined = ID;
   }
 
-  /// isExplicitlyDefaulted - Whether this constructor was explicitly defaulted.
-  bool isExplicitlyDefaulted() const {
-    return ExplicitlyDefaulted;
-  }
-  /// setExplicitlyDefaulted - Set whether this contructor was explicitly
-  /// defaulted or not.
-  void setExplicitlyDefaulted(bool B) {
-    ExplicitlyDefaulted = B;
-  }
-
-  /// isDefaulted - True if this was either explicitly defaulted or is implicit
-  bool isDefaulted() const {
-    return ExplicitlyDefaulted || isImplicit();
-  }
-
-  /// isUserProvided - True if this function was neither defaulted nor deleted
-  /// on its first declaration.
-  bool isUserProvided() const {
-    const CXXConstructorDecl *Canonical = getCanonicalDecl();
-    return !Canonical->isDefaulted() && !Canonical->isDeleted();
-  }
-
   /// init_iterator - Iterates through the member/base initializer list.
   typedef CXXCtorInitializer **init_iterator;
 
index 166f81a5ffe111d9482165a16022d04078c78ccd..0b0bca0395cb685fd8710cdb691605686fb953d8 100644 (file)
@@ -52,10 +52,6 @@ def err_invalid_storage_class_in_func_decl : Error<
 def err_expected_namespace_name : Error<"expected namespace name">;
 def ext_variadic_templates : ExtWarn<
   "variadic templates are a C++0x extension">, InGroup<CXX0x>;
-def err_default_special_members : Error<
-  "Only special member functions may be defaulted">;
-def err_friends_define_only_namespace_scope : Error<
-  "Cannot define a function with non-namespace scope in a friend declaration">;
 
 // Sema && Lex
 def ext_longlong : Extension<
index 3a8a708afa0bc3b5ac993f8488351abc9a088c0c..e2d7f4ce9a73fca1cd69f4392a0706b4aa071946 100644 (file)
@@ -434,9 +434,6 @@ def err_missing_whitespace_digraph : Error<
 
 def warn_deleted_function_accepted_as_extension: ExtWarn<
   "deleted function definition accepted as a C++0x extension">, InGroup<CXX0x>;
-def warn_defaulted_function_accepted_as_extension: ExtWarn<
-  "defaulted function definition accepted as a C++0x extension">,
-  InGroup<CXX0x>;
 
 // C++0x alias-declaration
 def ext_alias_declaration : ExtWarn<
index 4f8a61570e78bc7d12197478c843641f0730fde6..69e14f3c0b90cc58107a029665501249f778d34d 100644 (file)
@@ -3063,7 +3063,7 @@ public:
                                  MultiTemplateParamsArg TemplateParameterLists,
                                  Expr *BitfieldWidth, const VirtSpecifiers &VS,
                                  Expr *Init, bool IsDefinition,
-                                 bool Deleted = false, bool Defaulted = false);
+                                 bool Deleted = false);
 
   MemInitResult ActOnMemInitializer(Decl *ConstructorD,
                                     Scope *S,
index 8e95cfecf4cfdbd8838f3d7d57ecf66185c8c04e..dc881ba86960018acc3c0a88e0d542704ffddc3d 100644 (file)
@@ -2397,8 +2397,7 @@ Decl *ASTNodeImporter::VisitFunctionDecl(FunctionDecl *D) {
                                             NameInfo, T, TInfo, 
                                             FromConstructor->isExplicit(),
                                             D->isInlineSpecified(), 
-                                            D->isImplicit(),
-                                      FromConstructor->isExplicitlyDefaulted());
+                                            D->isImplicit());
   } else if (isa<CXXDestructorDecl>(D)) {
     ToFunction = CXXDestructorDecl::Create(Importer.getToContext(),
                                            cast<CXXRecordDecl>(DC),
index ce2d81192994c7e9923c9f640406997a54b2ebdd..9099cd524f1a29e949e3938bae2e7219a03d7822 100644 (file)
@@ -1301,7 +1301,7 @@ SourceRange CXXCtorInitializer::getSourceRange() const {
 CXXConstructorDecl *
 CXXConstructorDecl::Create(ASTContext &C, EmptyShell Empty) {
   return new (C) CXXConstructorDecl(0, SourceLocation(), DeclarationNameInfo(),
-                                    QualType(), 0, false, false, false, false);
+                                    QualType(), 0, false, false, false);
 }
 
 CXXConstructorDecl *
@@ -1311,14 +1311,12 @@ CXXConstructorDecl::Create(ASTContext &C, CXXRecordDecl *RD,
                            QualType T, TypeSourceInfo *TInfo,
                            bool isExplicit,
                            bool isInline,
-                           bool isImplicitlyDeclared,
-                           bool isExplicitlyDefaulted) {
+                           bool isImplicitlyDeclared) {
   assert(NameInfo.getName().getNameKind()
          == DeclarationName::CXXConstructorName &&
          "Name must refer to a constructor");
   return new (C) CXXConstructorDecl(RD, StartLoc, NameInfo, T, TInfo,
-                                    isExplicit, isInline, isImplicitlyDeclared,
-                                    isExplicitlyDefaulted);
+                                    isExplicit, isInline, isImplicitlyDeclared);
 }
 
 bool CXXConstructorDecl::isDefaultConstructor() const {
index 1eaae678e2ff779dd3b37f59b6dd4404c671c219..a20e90bd0ea38f3d0d7e4e4f201e84afd1ff32de 100644 (file)
@@ -966,11 +966,6 @@ Decl *Parser::ParseDeclarationAfterDeclaratorAndAttributes(Declarator &D,
         Diag(DelLoc, diag::warn_deleted_function_accepted_as_extension);
 
       Actions.SetDeclDeleted(ThisDecl, DelLoc);
-    } else if (Tok.is(tok::kw_default)) {
-      SourceLocation DefLoc = ConsumeToken();
-      Diag(DefLoc, diag::err_default_special_members);
-
-      ThisDecl->setInvalidDecl();
     } else {
       if (getLang().CPlusPlus && D.getCXXScopeSpec().isSet()) {
         EnterScope(0);
index 9c464bc248507e2a72fbd7819a4ba07d7eeac3f3..7247c0724e4cf96073b70272d97f9faa2aef896f 100644 (file)
@@ -1648,8 +1648,6 @@ void Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS,
   ExprResult BitfieldSize;
   ExprResult Init;
   bool Deleted = false;
-  bool Defaulted = false;
-  SourceLocation DefLoc;
 
   while (1) {
     // member-declarator:
@@ -1681,11 +1679,6 @@ void Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS,
           Diag(Tok, diag::warn_deleted_function_accepted_as_extension);
         ConsumeToken();
         Deleted = true;
-      } else if (Tok.is(tok::kw_delete)) {
-        if (!getLang().CPlusPlus0x)
-          Diag(Tok, diag::warn_defaulted_function_accepted_as_extension);
-        DefLoc = ConsumeToken();
-        Defaulted = true;
       } else {
         Init = ParseInitializer();
         if (Init.isInvalid())
@@ -1717,10 +1710,6 @@ void Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS,
       ThisDecl = Actions.ActOnFriendFunctionDecl(getCurScope(), DeclaratorInfo,
                                                  /*IsDefinition*/ false,
                                                  move(TemplateParams));
-      if (Defaulted) {
-        Diag(DefLoc, diag::err_friends_define_only_namespace_scope);
-        ThisDecl->setInvalidDecl();
-      }
     } else {
       ThisDecl = Actions.ActOnCXXMemberDeclarator(getCurScope(), AS,
                                                   DeclaratorInfo,
@@ -1728,7 +1717,7 @@ void Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS,
                                                   BitfieldSize.release(),
                                                   VS, Init.release(),
                                                   /*IsDefinition*/Deleted,
-                                                  Deleted, Defaulted);
+                                                  Deleted);
     }
     if (ThisDecl)
       DeclsInGroup.push_back(ThisDecl);
@@ -1755,7 +1744,6 @@ void Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS,
     BitfieldSize = 0;
     Init = 0;
     Deleted = false;
-    Defaulted = false;
 
     // Attributes are only allowed on the second declarator.
     MaybeParseGNUAttributes(DeclaratorInfo);
index 7845247a2494462c3d70aa6c6de1e65012a93ca4..2a63c9113587f3d302035d395097df757ef12645 100644 (file)
@@ -4109,8 +4109,7 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
                                          D.getSourceRange().getBegin(),
                                          NameInfo, R, TInfo,
                                          isExplicit, isInline,
-                                         /*isImplicitlyDeclared=*/false,
-                                         /*isExplicitlyDefaulted=*/false);
+                                         /*isImplicitlyDeclared=*/false);
     } else if (Name.getNameKind() == DeclarationName::CXXDestructorName) {
       // This is a C++ destructor declaration.
       if (DC->isRecord()) {
index 6dad78442ddfc76bc8ba1fa9f17cd3fcab19ff0e..525cb81c8071ae6017575f14adf2e3792395019f 100644 (file)
@@ -963,10 +963,7 @@ Sema::ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS, Declarator &D,
                                MultiTemplateParamsArg TemplateParameterLists,
                                ExprTy *BW, const VirtSpecifiers &VS,
                                ExprTy *InitExpr, bool IsDefinition,
-                               bool Deleted, bool Defaulted) {
-  // FIXME: Do something with this
-  (void) Defaulted;
-
+                               bool Deleted) {
   const DeclSpec &DS = D.getDeclSpec();
   DeclarationNameInfo NameInfo = GetNameForDeclarator(D);
   DeclarationName Name = NameInfo.getName();
@@ -5051,8 +5048,7 @@ CXXConstructorDecl *Sema::DeclareImplicitDefaultConstructor(
                                  /*TInfo=*/0,
                                  /*isExplicit=*/false,
                                  /*isInline=*/true,
-                                 /*isImplicitlyDeclared=*/true,
-                                 /*isExplicitlyDefaulted=*/false);
+                                 /*isImplicitlyDeclared=*/true);
   DefaultCon->setAccess(AS_public);
   DefaultCon->setImplicit();
   DefaultCon->setTrivial(ClassDecl->hasTrivialConstructor());
@@ -5248,8 +5244,7 @@ void Sema::DeclareInheritedConstructors(CXXRecordDecl *ClassDecl) {
         CXXConstructorDecl *NewCtor = CXXConstructorDecl::Create(
             Context, ClassDecl, UsingLoc, DNI, QualType(NewCtorType, 0),
             /*TInfo=*/0, BaseCtor->isExplicit(), /*Inline=*/true,
-            /*ImplicitlyDeclared=*/true,
-            /*isExplicitlyDefaulted*/false);
+            /*ImplicitlyDeclared=*/true);
         NewCtor->setAccess(BaseCtor->getAccess());
 
         // Build up the parameter decls and add them.
@@ -6198,8 +6193,7 @@ CXXConstructorDecl *Sema::DeclareImplicitCopyConstructor(
                                  /*TInfo=*/0,
                                  /*isExplicit=*/false,
                                  /*isInline=*/true,
-                                 /*isImplicitlyDeclared=*/true,
-                                 /*isExplicitlyDefaulted=*/false);
+                                 /*isImplicitlyDeclared=*/true);
   CopyConstructor->setAccess(AS_public);
   CopyConstructor->setTrivial(ClassDecl->hasTrivialCopyConstructor());
   
index 2c0c7ae90ff8a09eabb640cd4bb72a2952b397fb..f6cbe267b4e2e4ce67e93047da0a96efb1873320 100644 (file)
@@ -1375,8 +1375,7 @@ TemplateDeclInstantiator::VisitCXXMethodDecl(CXXMethodDecl *D,
                                         StartLoc, NameInfo, T, TInfo,
                                         Constructor->isExplicit(),
                                         Constructor->isInlineSpecified(),
-                                        false,
-                                        Constructor->isExplicitlyDefaulted());
+                                        false);
   } else if (CXXDestructorDecl *Destructor = dyn_cast<CXXDestructorDecl>(D)) {
     Method = CXXDestructorDecl::Create(SemaRef.Context, Record,
                                        StartLoc, NameInfo, T, TInfo,