Get rid of [[hiding]], [[override]] and [[base_check]].

llvm-svn: 124087
This commit is contained in:
Anders Carlsson 2011-01-23 21:33:18 +00:00
parent dfac4ccdb7
commit e30621b626
9 changed files with 1 additions and 221 deletions

View 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"];
}

View 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.

View 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();

View 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)

View 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);

View 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;

View File

@ -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}}
};

View File

@ -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'}}
};
}
}

View 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}}
};