r194872 - PR17949: Fix crash if someone puts a namespace inside a class template.
Richard Smith
richard-llvm at metafoo.co.uk
Fri Nov 15 15:00:02 PST 2013
Author: rsmith
Date: Fri Nov 15 17:00:02 2013
New Revision: 194872
URL: http://llvm.org/viewvc/llvm-project?rev=194872&view=rev
Log:
PR17949: Fix crash if someone puts a namespace inside a class template.
Modified:
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
cfe/trunk/test/Parser/recovery.cpp
Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=194872&r1=194871&r2=194872&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Fri Nov 15 17:00:02 2013
@@ -465,9 +465,9 @@ def err_expected_member_or_base_name : E
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>;
Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=194872&r1=194871&r2=194872&view=diff
==============================================================================
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Fri Nov 15 17:00:02 2013
@@ -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());
Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=194872&r1=194871&r2=194872&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Fri Nov 15 17:00:02 2013
@@ -2627,7 +2627,7 @@ void Parser::ParseCXXMemberSpecification
// 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
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);
Modified: cfe/trunk/test/Parser/recovery.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/recovery.cpp?rev=194872&r1=194871&r2=194872&view=diff
==============================================================================
--- cfe/trunk/test/Parser/recovery.cpp (original)
+++ cfe/trunk/test/Parser/recovery.cpp Fri Nov 15 17:00:02 2013
@@ -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 {
More information about the cfe-commits
mailing list