From cddbc1d5872c96cd8c3ad3ddededa304757270d7 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Thu, 6 Sep 2012 18:32:18 +0000 Subject: [PATCH] Don't try to check override control for invalid member functions. Fixes a crash in a corner case. Patch by Olivier Goffart! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163337 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaDeclCXX.cpp | 3 +++ test/SemaTemplate/nested-template.cpp | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index 2a221d8e5d..318342ec76 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -1420,6 +1420,9 @@ bool Sema::ActOnAccessSpecifier(AccessSpecifier Access, /// CheckOverrideControl - Check C++11 override control semantics. void Sema::CheckOverrideControl(Decl *D) { + if (D->isInvalidDecl()) + return; + const CXXMethodDecl *MD = dyn_cast(D); // Do we know which functions this declaration might be overriding? diff --git a/test/SemaTemplate/nested-template.cpp b/test/SemaTemplate/nested-template.cpp index 7849bae4d5..47502536ca 100644 --- a/test/SemaTemplate/nested-template.cpp +++ b/test/SemaTemplate/nested-template.cpp @@ -155,3 +155,8 @@ namespace PR10924 { { }; } + +class Outer1 { + template struct X; + template int X::func() {} // expected-error{{out-of-line definition of 'func' from class 'X' without definition}} +}; -- 2.40.0