forked from OSchip/llvm-project
Sema: RecordDecl shouldn't have a FunctionDecl as a Decl
RecordDecls should have things like CXXMethodDecls or FriendDecls as a decl but not things like FunctionDecls. llvm-svn: 225511
This commit is contained in:
parent
b68fa3b576
commit
aa30dd7497
|
@ -6712,6 +6712,11 @@ static FunctionDecl* CreateNewFunctionDecl(Sema &SemaRef, Declarator &D,
|
|||
IsVirtualOkay = !Ret->isStatic();
|
||||
return Ret;
|
||||
} else {
|
||||
bool isFriend =
|
||||
SemaRef.getLangOpts().CPlusPlus && D.getDeclSpec().isFriendSpecified();
|
||||
if (!isFriend && SemaRef.CurContext->isRecord())
|
||||
return nullptr;
|
||||
|
||||
// Determine whether the function was written with a
|
||||
// prototype. This true when:
|
||||
// - we're in C++ (where every function has a prototype),
|
||||
|
@ -7482,7 +7487,7 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC,
|
|||
} else if (isFunctionTemplateSpecialization) {
|
||||
if (CurContext->isDependentContext() && CurContext->isRecord()
|
||||
&& !isFriend) {
|
||||
isDependentClassScopeExplicitSpecialization = isa<CXXMethodDecl>(NewFD);
|
||||
isDependentClassScopeExplicitSpecialization = true;
|
||||
Diag(NewFD->getLocation(), getLangOpts().MicrosoftExt ?
|
||||
diag::ext_function_specialization_in_class :
|
||||
diag::err_function_specialization_in_class)
|
||||
|
|
|
@ -199,5 +199,11 @@ namespace PR22040 {
|
|||
template <typename>
|
||||
struct SpecializationOfGlobalFnInClassScope {
|
||||
template <>
|
||||
void ::Fn(); // expected-error{{cannot have a qualified name}} expected-error{{cannot specialize a function}}
|
||||
void ::Fn(); // expected-error{{cannot have a qualified name}}
|
||||
};
|
||||
|
||||
class AbstractClassWithGlobalFn {
|
||||
template <typename>
|
||||
void ::f(); // expected-error{{cannot have a qualified name}}
|
||||
virtual void f1() = 0;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue