let Spellings = ["dllimport"];
}
-def Explicit : InheritableAttr {
- let Spellings = [];
-}
-
def FastCall : InheritableAttr {
let Spellings = ["fastcall", "__fastcall"];
}
def err_final_base : Error<
"derivation from 'final' %0">;
-def err_function_overriding_without_override : Error<
- "%0 overrides function%s1 without being marked 'override'">;
-
// C++0x scoped enumerations
def err_enum_invalid_underlying : Error<
"non-integral type %0 is an invalid underlying type">;
/// C++ record definition's base-specifiers clause and are starting its
/// member declarations.
void ActOnStartCXXMemberDeclarations(Scope *S, Decl *TagDecl,
- ClassVirtSpecifiers &CVS,
+ SourceLocation FinalLoc,
SourceLocation LBraceLoc);
/// ActOnTagFinishDefinition - Invoked once we have finished parsing
SourceLocation LBraceLoc = ConsumeBrace();
+ SourceLocation FinalLoc =
+ CVS.isFinalSpecified() ? CVS.getFinalLoc() : SourceLocation();
+
if (TagDecl)
- Actions.ActOnStartCXXMemberDeclarations(getCurScope(), TagDecl, CVS,
+ Actions.ActOnStartCXXMemberDeclarations(getCurScope(), TagDecl, FinalLoc,
LBraceLoc);
// C++ 11p3: Members of a class defined with the keyword class are private
}
void Sema::ActOnStartCXXMemberDeclarations(Scope *S, Decl *TagD,
- ClassVirtSpecifiers &CVS,
+ SourceLocation FinalLoc,
SourceLocation LBraceLoc) {
AdjustDeclIfTemplate(TagD);
CXXRecordDecl *Record = cast<CXXRecordDecl>(TagD);
if (!Record->getIdentifier())
return;
- if (CVS.isFinalSpecified())
- Record->addAttr(new (Context) FinalAttr(CVS.getFinalLoc(), Context));
- if (CVS.isExplicitSpecified())
- Record->addAttr(new (Context) ExplicitAttr(CVS.getExplicitLoc(), Context));
+ if (FinalLoc.isValid())
+ Record->addAttr(new (Context) FinalAttr(FinalLoc, Context));
// C++ [class]p2:
// [...] The class-name is also inserted into the scope of the
<< MD->getDeclName();
return;
}
-
- // C++0x [class.derived]p8:
- // In a class definition marked with the class-virt-specifier explicit,
- // 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 with the virt-specifier override, the program is ill-formed.
- if (MD->getParent()->hasAttr<ExplicitAttr>() && !isa<CXXDestructorDecl>(MD) &&
- HasOverriddenMethods && !MD->hasAttr<OverrideAttr>()) {
- llvm::SmallVector<const CXXMethodDecl*, 4>
- OverriddenMethods(MD->begin_overridden_methods(),
- MD->end_overridden_methods());
-
- Diag(MD->getLocation(), diag::err_function_overriding_without_override)
- << MD->getDeclName()
- << (unsigned)OverriddenMethods.size();
-
- for (unsigned I = 0; I != OverriddenMethods.size(); ++I)
- Diag(OverriddenMethods[I]->getLocation(),
- diag::note_overridden_virtual_function);
- }
}
/// CheckIfOverriddenFunctionIsMarkedFinal - Checks whether a virtual member
+++ /dev/null
-// RUN: %clang_cc1 %s -fsyntax-only -verify -std=c++0x
-
-namespace Test1 {
-
-struct A {
- virtual void f(); // expected-note {{overridden virtual function is here}}
-};
-
-struct B explicit : A {
- virtual void f(); // expected-error {{overrides function without being marked 'override'}}
-};
-
-struct C {
- virtual ~C();
-};
-
-struct D explicit : C {
- virtual ~D();
-};
-
-}
-