diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-11-15 23:00:02 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-11-15 23:00:02 +0000 |
commit | 2ac43ad8db6e83c887af80b9c82f160599a5f66b (patch) | |
tree | 6c23c952b081e02cc098ebd2245a5485dd83a6ea /clang | |
parent | 4201ddf3686b8c6a330ee1cc5959950309968e6e (diff) | |
download | bcm5719-llvm-2ac43ad8db6e83c887af80b9c82f160599a5f66b.tar.gz bcm5719-llvm-2ac43ad8db6e83c887af80b9c82f160599a5f66b.zip |
PR17949: Fix crash if someone puts a namespace inside a class template.
llvm-svn: 194872
Diffstat (limited to 'clang')
-rw-r--r-- | clang/include/clang/Basic/DiagnosticParseKinds.td | 4 | ||||
-rw-r--r-- | clang/include/clang/Parse/Parser.h | 2 | ||||
-rw-r--r-- | clang/lib/Parse/ParseDeclCXX.cpp | 10 | ||||
-rw-r--r-- | clang/test/Parser/recovery.cpp | 5 |
4 files changed, 13 insertions, 8 deletions
diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td b/clang/include/clang/Basic/DiagnosticParseKinds.td index b895f3337ac..4d0641de549 100644 --- a/clang/include/clang/Basic/DiagnosticParseKinds.td +++ b/clang/include/clang/Basic/DiagnosticParseKinds.td @@ -465,9 +465,9 @@ def err_expected_member_or_base_name : Error< def err_expected_lbrace_after_base_specifiers : Error< "expected '{' after base class list">; def err_missing_end_of_definition : Error< - "missing '}' at end of definition of %0">; + "missing '}' at end of definition of %q0">; def note_missing_end_of_definition_before : Note< - "still within definition of %0 here">; + "still within definition of %q0 here">; def ext_ellipsis_exception_spec : Extension< "exception specification of '...' is a Microsoft extension">, InGroup<Microsoft>; diff --git a/clang/include/clang/Parse/Parser.h b/clang/include/clang/Parse/Parser.h index 1b26bba875a..01dafba6460 100644 --- a/clang/include/clang/Parse/Parser.h +++ b/clang/include/clang/Parse/Parser.h @@ -2084,7 +2084,7 @@ private: isCXX11AttributeSpecifier(bool Disambiguate = false, bool OuterMightBeMessageSend = false); - void DiagnoseUnexpectedNamespace(DeclContext *Context); + void DiagnoseUnexpectedNamespace(NamedDecl *Context); Decl *ParseNamespace(unsigned Context, SourceLocation &DeclEnd, SourceLocation InlineLoc = SourceLocation()); diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp index 3c534f7f275..0c3eab41f90 100644 --- a/clang/lib/Parse/ParseDeclCXX.cpp +++ b/clang/lib/Parse/ParseDeclCXX.cpp @@ -2627,7 +2627,7 @@ void Parser::ParseCXXMemberSpecification(SourceLocation RecordLoc, // If we see a namespace here, a close brace was missing somewhere. if (Tok.is(tok::kw_namespace)) { - DiagnoseUnexpectedNamespace(cast<DeclContext>(TagDecl)); + DiagnoseUnexpectedNamespace(cast<NamedDecl>(TagDecl)); break; } @@ -2722,15 +2722,15 @@ void Parser::ParseCXXMemberSpecification(SourceLocation RecordLoc, ClassScope.Exit(); } -void Parser::DiagnoseUnexpectedNamespace(DeclContext *Ctx) { +void Parser::DiagnoseUnexpectedNamespace(NamedDecl *D) { assert(Tok.is(tok::kw_namespace)); // FIXME: Suggest where the close brace should have gone by looking // at indentation changes within the definition body. - Diag(cast<Decl>(Ctx)->getLocation(), - diag::err_missing_end_of_definition) << Ctx; + Diag(D->getLocation(), + diag::err_missing_end_of_definition) << D; Diag(Tok.getLocation(), - diag::note_missing_end_of_definition_before) << Ctx; + diag::note_missing_end_of_definition_before) << D; // Push '};' onto the token stream to recover. PP.EnterToken(Tok); diff --git a/clang/test/Parser/recovery.cpp b/clang/test/Parser/recovery.cpp index 54e1b0adf2e..0000f5c5428 100644 --- a/clang/test/Parser/recovery.cpp +++ b/clang/test/Parser/recovery.cpp @@ -44,6 +44,11 @@ namespace MissingBrace { int k1 = S().h(); // expected-error {{no member named 'h' in 'MissingBrace::S'}} int k2 = S().f() + N::g(); + + template<typename T> struct PR17949 { // expected-error {{missing '}' at end of definition of 'MissingBrace::PR17949'}} + + namespace X { // expected-note {{still within definition of 'MissingBrace::PR17949' here}} + } } namespace N { |