]> granicus.if.org Git - clang/commitdiff
Get rid of [[hiding]], [[override]] and [[base_check]].
authorAnders Carlsson <andersca@mac.com>
Sun, 23 Jan 2011 21:33:18 +0000 (21:33 +0000)
committerAnders Carlsson <andersca@mac.com>
Sun, 23 Jan 2011 21:33:18 +0000 (21:33 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124087 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/Attr.td
include/clang/Sema/AttributeList.h
lib/Parse/ParseDeclCXX.cpp
lib/Sema/AttributeList.cpp
lib/Sema/SemaDecl.cpp
lib/Sema/SemaDeclAttr.cpp
test/CXX/dcl.dcl/dcl.attr/dcl.attr.override/p1.cpp [deleted file]
test/CXX/dcl.dcl/dcl.attr/dcl.attr.override/p6.cpp [deleted file]
test/SemaCXX/attr-cxx0x.cpp

index 38c67b29640bc674fe980f9fd37daf45887e5efb..9a13ce639102d37eb0b5679872721032644e09b9 100644 (file)
@@ -129,12 +129,6 @@ def AsmLabel : InheritableAttr {
   let Args = [StringArgument<"Label">];
 }
 
-def BaseCheck : InheritableAttr {
-  let Spellings = ["base_check"];
-  let Subjects = [CXXRecord];
-  let Namespaces = ["", "std"];
-}
-
 def Blocks : InheritableAttr {
   let Spellings = ["blocks"];
   let Args = [EnumArgument<"Type", "BlockType", ["byref"], ["ByRef"]>];
@@ -238,12 +232,6 @@ def GNUInline : InheritableAttr {
   let Spellings = ["gnu_inline"];
 }
 
-def Hiding : InheritableAttr {
-  let Spellings = ["hiding"];
-  let Subjects = [Field, CXXMethod];
-  let Namespaces = ["", "std"];
-}
-
 def IBAction : InheritableAttr {
   let Spellings = ["ibaction"];
 }
@@ -344,12 +332,6 @@ def ObjCNSObject : InheritableAttr {
   let Spellings = ["NSOjbect"];
 }
 
-def Override : InheritableAttr {
-  let Spellings = ["override"];
-  let Subjects = [CXXVirtualMethod];
-  let Namespaces = ["", "std"];
-}
-
 def Overloadable : Attr {
   let Spellings = ["overloadable"];
 }
index 99005e38e4e6207c03d4ff70bfd596aa52dcee01..432611858bbba66c539a9f55e010857a6fd06b19 100644 (file)
@@ -108,7 +108,6 @@ public:
     AT_format_arg,
     AT_global,
     AT_gnu_inline,
-    AT_hiding,
     AT_host,
     AT_launch_bounds,
     AT_malloc,
@@ -126,7 +125,6 @@ public:
     AT_nothrow,
     AT_nsobject,
     AT_objc_exception,
-    AT_override,
     AT_cf_returns_not_retained, // Clang-specific.
     AT_cf_returns_retained,     // Clang-specific.
     AT_ns_returns_not_retained, // Clang-specific.
index 44c69217150672dd7cdacb94ede175d30e7bfc51..b077f73baa332c5ecb29a72e1234e1721764b97c 100644 (file)
@@ -2221,11 +2221,8 @@ void Parser::ParseCXX0XAttributes(ParsedAttributesWithRange &attrs,
       switch(AttributeList::getKind(AttrName))
       {
       // No arguments
-      case AttributeList::AT_base_check:
       case AttributeList::AT_carries_dependency:
-      case AttributeList::AT_hiding:
-      case AttributeList::AT_noreturn:
-      case AttributeList::AT_override: {
+      case AttributeList::AT_noreturn: {
         if (Tok.is(tok::l_paren)) {
           Diag(Tok.getLocation(), diag::err_cxx0x_attribute_forbids_arguments)
             << AttrName->getName();
index d8d0c7b1a70867fe8a01569e82cd41851334bff6..f5149a3ce53c9d1abb4001e3ade0166783f3d748 100644 (file)
@@ -56,7 +56,6 @@ AttributeList::Kind AttributeList::getKind(const IdentifierInfo *Name) {
     .Case("__const", AT_const) // some GCC headers do contain this spelling
     .Case("blocks", AT_blocks)
     .Case("format", AT_format)
-    .Case("hiding", AT_hiding)
     .Case("malloc", AT_malloc)
     .Case("packed", AT_packed)
     .Case("unused", AT_unused)
@@ -77,7 +76,6 @@ AttributeList::Kind AttributeList::getKind(const IdentifierInfo *Name) {
     .Case("iboutletcollection", AT_IBOutletCollection)
     .Case("noreturn", AT_noreturn)
     .Case("noinline", AT_noinline)
-    .Case("override", AT_override)
     .Case("sentinel", AT_sentinel)
     .Case("NSObject", AT_nsobject)
     .Case("dllimport", AT_dllimport)
index 62adcf9bb1998165aa14af13afe2d0953bd1ef56..85df57a76c7af5b6fcdda2e776e64604437f994d 100644 (file)
@@ -3372,52 +3372,6 @@ static void DiagnoseInvalidRedeclaration(Sema &S, FunctionDecl *NewFD) {
   }
 }
 
-/// CheckClassMemberNameAttributes - Check for class member name checking
-/// attributes according to [dcl.attr.override]
-static void 
-CheckClassMemberNameAttributes(Sema& SemaRef, const FunctionDecl *FD) {
-  const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD);
-  if (!MD || !MD->isVirtual())
-    return;
-
-  bool HasOverrideAttr = MD->hasAttr<OverrideAttr>();
-  bool HasOverriddenMethods = 
-    MD->begin_overridden_methods() != MD->end_overridden_methods();
-
-  /// C++ [dcl.attr.override]p2:
-  ///   If a virtual member function f is marked override and does not override
-  ///   a member function of a base class the program is ill-formed.
-  if (HasOverrideAttr && !HasOverriddenMethods) {
-    SemaRef.Diag(MD->getLocation(), 
-                 diag::err_function_marked_override_not_overriding)
-      << MD->getDeclName();
-    return;
-  }
-
-  if (!MD->getParent()->hasAttr<BaseCheckAttr>())
-    return;
-
-  /// C++ [dcl.attr.override]p6:
-  ///   In a class definition marked base_check, if a virtual member function
-  ///    that is neither implicitly-declared nor a destructor overrides a 
-  ///    member function of a base class and it is not marked override, the
-  ///    program is ill-formed.
-  if (HasOverriddenMethods && !HasOverrideAttr && !MD->isImplicit() &&
-      !isa<CXXDestructorDecl>(MD)) {
-    llvm::SmallVector<const CXXMethodDecl*, 4> 
-      OverriddenMethods(MD->begin_overridden_methods(), 
-                        MD->end_overridden_methods());
-
-    SemaRef.Diag(MD->getLocation(), 
-                 diag::err_function_overriding_without_override)
-      << MD->getDeclName() << (unsigned)OverriddenMethods.size();
-
-    for (unsigned I = 0; I != OverriddenMethods.size(); ++I)
-      SemaRef.Diag(OverriddenMethods[I]->getLocation(),
-                   diag::note_overridden_virtual_function);
-  }
-}
-
 NamedDecl*
 Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
                               QualType R, TypeSourceInfo *TInfo,
@@ -4095,7 +4049,6 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
         FunctionTemplate->setInvalidDecl();
       return FunctionTemplate;
     }
-    CheckClassMemberNameAttributes(*this, NewFD);
   }
 
   MarkUnusedFileScopedDecl(NewFD);
index 88afaf30b75b091959c6cf4a4638b51eb8aab976..dce229b6287f8ef94344387dba8d8d27c07aefd6 100644 (file)
@@ -2437,82 +2437,6 @@ static void HandleLaunchBoundsAttr(Decl *d, const AttributeList &Attr, Sema &S){
   }
 }
 
-//===----------------------------------------------------------------------===//
-// C++0x member checking attributes
-//===----------------------------------------------------------------------===//
-
-static void HandleBaseCheckAttr(Decl *d, const AttributeList &Attr, Sema &S) {
-  if (Attr.getNumArgs() != 0) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 0;
-    return;
-  }
-  
-  if (!isa<CXXRecordDecl>(d)) {
-    S.Diag(Attr.getLoc(),
-           Attr.isCXX0XAttribute() ? diag::err_attribute_wrong_decl_type
-                                   : diag::warn_attribute_wrong_decl_type)
-      << Attr.getName() << 9 /*class*/;
-    return;
-  }
-  
-  if (d->getAttr<BaseCheckAttr>()) {
-    S.Diag(Attr.getLoc(), diag::err_repeat_attribute) << "base_check";
-    return;
-  }
-  
-  d->addAttr(::new (S.Context) BaseCheckAttr(Attr.getLoc(), S.Context));
-}
-
-static void HandleHidingAttr(Decl *d, const AttributeList &Attr, Sema &S) {
-  if (Attr.getNumArgs() != 0) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 0;
-    return;
-  }
-
-  if (!isa<RecordDecl>(d->getDeclContext())) {
-    // FIXME: It's not the type that's the problem
-    S.Diag(Attr.getLoc(),
-           Attr.isCXX0XAttribute() ? diag::err_attribute_wrong_decl_type
-                                   : diag::warn_attribute_wrong_decl_type)
-      << Attr.getName() << 11 /*member*/;
-    return;
-  }
-
-  // FIXME: Conform to C++0x redeclaration rules.
-
-  if (d->getAttr<HidingAttr>()) {
-    S.Diag(Attr.getLoc(), diag::err_repeat_attribute) << "hiding";
-    return;
-  }
-
-  d->addAttr(::new (S.Context) HidingAttr(Attr.getLoc(), S.Context));
-}
-
-static void HandleOverrideAttr(Decl *d, const AttributeList &Attr, Sema &S) {
-  if (Attr.getNumArgs() != 0) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 0;
-    return;
-  }
-
-  if (!isa<CXXMethodDecl>(d) || !cast<CXXMethodDecl>(d)->isVirtual()) {
-    // FIXME: It's not the type that's the problem
-    S.Diag(Attr.getLoc(),
-           Attr.isCXX0XAttribute() ? diag::err_attribute_wrong_decl_type
-                                   : diag::warn_attribute_wrong_decl_type)
-      << Attr.getName() << 10 /*virtual method*/;
-    return;
-  }
-
-  // FIXME: Conform to C++0x redeclaration rules.
-
-  if (d->getAttr<OverrideAttr>()) {
-    S.Diag(Attr.getLoc(), diag::err_repeat_attribute) << "override";
-    return;
-  }
-
-  d->addAttr(::new (S.Context) OverrideAttr(Attr.getLoc(), S.Context));
-}
-
 //===----------------------------------------------------------------------===//
 // Checker-specific attribute handlers.
 //===----------------------------------------------------------------------===//
@@ -2672,7 +2596,6 @@ static void ProcessInheritableDeclAttr(Scope *scope, Decl *D,
   case AttributeList::AT_analyzer_noreturn:
     HandleAnalyzerNoReturnAttr  (D, Attr, S); break;
   case AttributeList::AT_annotate:    HandleAnnotateAttr    (D, Attr, S); break;
-  case AttributeList::AT_base_check:  HandleBaseCheckAttr   (D, Attr, S); break;
   case AttributeList::AT_carries_dependency:
                                       HandleDependencyAttr  (D, Attr, S); break;
   case AttributeList::AT_common:      HandleCommonAttr      (D, Attr, S); break;
@@ -2687,7 +2610,6 @@ static void ProcessInheritableDeclAttr(Scope *scope, Decl *D,
   case AttributeList::AT_format_arg:  HandleFormatArgAttr   (D, Attr, S); break;
   case AttributeList::AT_global:      HandleGlobalAttr      (D, Attr, S); break;
   case AttributeList::AT_gnu_inline:  HandleGNUInlineAttr   (D, Attr, S); break;
-  case AttributeList::AT_hiding:      HandleHidingAttr      (D, Attr, S); break;
   case AttributeList::AT_launch_bounds:
     HandleLaunchBoundsAttr(D, Attr, S);
     break;
@@ -2703,7 +2625,6 @@ static void ProcessInheritableDeclAttr(Scope *scope, Decl *D,
   case AttributeList::AT_naked:       HandleNakedAttr       (D, Attr, S); break;
   case AttributeList::AT_noreturn:    HandleNoReturnAttr    (D, Attr, S); break;
   case AttributeList::AT_nothrow:     HandleNothrowAttr     (D, Attr, S); break;
-  case AttributeList::AT_override:    HandleOverrideAttr    (D, Attr, S); break;
   case AttributeList::AT_shared:      HandleSharedAttr      (D, Attr, S); break;
   case AttributeList::AT_vecreturn:   HandleVecReturnAttr   (D, Attr, S); break;
 
diff --git a/test/CXX/dcl.dcl/dcl.attr/dcl.attr.override/p1.cpp b/test/CXX/dcl.dcl/dcl.attr/dcl.attr.override/p1.cpp
deleted file mode 100644 (file)
index 3bf9f4f..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s
-
-struct A {
-  virtual void f();
-  virtual void h();
-};
-
-struct B : A {
-  [[override]] virtual void f();
-  [[override]] void g(); // expected-error {{'override' attribute only applies to virtual method types}}
-  [[override, override]] void h(); // expected-error {{'override' attribute cannot be repeated}}
-};
diff --git a/test/CXX/dcl.dcl/dcl.attr/dcl.attr.override/p6.cpp b/test/CXX/dcl.dcl/dcl.attr/dcl.attr.override/p6.cpp
deleted file mode 100644 (file)
index e3e78c2..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s
-
-namespace Override {
-
-namespace Test1 {
-
-struct A {
-  virtual ~A();
-};
-
-struct [[base_check]] B : A { 
-  virtual ~B();
-};
-
-}
-
-namespace Test2 {
-
-struct A { 
-  virtual void f(); // expected-note {{overridden virtual function is here}}
-};
-
-struct [[base_check]] B : A {
-  virtual void f(); // expected-error {{'f' overrides function without being marked 'override'}}
-};
-  
-}
-
-namespace Test3 {
-
-struct A { 
-  virtual void f(); // expected-note {{overridden virtual function is here}}
-};
-
-struct B { 
-  virtual void f(); // expected-note {{overridden virtual function is here}}
-};
-
-struct [[base_check]] C : A, B {
-  virtual void f(); // expected-error {{'f' overrides functions without being marked 'override'}}
-};
-  
-}
-
-}
index 5570f672cc3c458a3a0e1881eebb50682e511ecc..40fe0e01c2e6b307c31f35f76b22d2dd59a0515f 100644 (file)
@@ -14,15 +14,3 @@ static_assert(alignof(align_small) == 1, "j's alignment is wrong");
 static_assert(alignof(align_multiple) == 8, "l's alignment is wrong");
 static_assert(alignof(align_member) == 8, "quuux's alignment is wrong");
 static_assert(sizeof(align_member) == 8, "quuux's size is wrong");
-
-int bc_fail [[base_check]]; // expected-error {{'base_check' attribute only applies to class types}}
-int hiding_fail [[hiding]]; // expected-error {{'hiding' attribute only applies to member types}}
-int override_fail [[override]]; // expected-error {{'override' attribute only applies to virtual method types}}
-
-struct base {
-  virtual void function();
-  virtual void other_function();
-};
-
-struct [[base_check, base_check]] bc : base { // expected-error {{'base_check' attribute cannot be repeated}}
-};