[cfe-commits] r109853 - in /cfe/trunk: lib/Parse/ParseDeclCXX.cpp test/SemaTemplate/class-template-id.cpp test/SemaTemplate/deduction-crash.cpp
John McCall
rjmccall at apple.com
Thu Jul 29 23:26:29 PDT 2010
Author: rjmccall
Date: Fri Jul 30 01:26:29 2010
New Revision: 109853
URL: http://llvm.org/viewvc/llvm-project?rev=109853&view=rev
Log:
Improve error recovery when presented with an ill-formed template-id
(e.g. due to a broken template argument) following template parameters.
Fixes rdar://problem/8254267
Modified:
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
cfe/trunk/test/SemaTemplate/class-template-id.cpp
cfe/trunk/test/SemaTemplate/deduction-crash.cpp
Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=109853&r1=109852&r2=109853&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Fri Jul 30 01:26:29 2010
@@ -680,7 +680,8 @@
// "FOO : BAR" is not a potential typo for "FOO::BAR".
ColonProtectionRAIIObject X(*this);
- ParseOptionalCXXScopeSpecifier(SS, /*ObjectType=*/0, true);
+ if (ParseOptionalCXXScopeSpecifier(SS, /*ObjectType=*/0, true))
+ DS.SetTypeSpecError();
if (SS.isSet())
if (Tok.isNot(tok::identifier) && Tok.isNot(tok::annot_template_id))
Diag(Tok, diag::err_expected_ident);
@@ -804,10 +805,13 @@
else
TUK = Action::TUK_Reference;
- if (!Name && !TemplateId && TUK != Action::TUK_Definition) {
- // We have a declaration or reference to an anonymous class.
- Diag(StartLoc, diag::err_anon_type_definition)
- << DeclSpec::getSpecifierName(TagType);
+ if (!Name && !TemplateId && (DS.getTypeSpecType() == DeclSpec::TST_error ||
+ TUK != Action::TUK_Definition)) {
+ if (DS.getTypeSpecType() != DeclSpec::TST_error) {
+ // We have a declaration or reference to an anonymous class.
+ Diag(StartLoc, diag::err_anon_type_definition)
+ << DeclSpec::getSpecifierName(TagType);
+ }
SkipUntil(tok::comma, true);
Modified: cfe/trunk/test/SemaTemplate/class-template-id.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/class-template-id.cpp?rev=109853&r1=109852&r2=109853&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/class-template-id.cpp (original)
+++ cfe/trunk/test/SemaTemplate/class-template-id.cpp Fri Jul 30 01:26:29 2010
@@ -41,3 +41,7 @@
template<typename T> struct Foo { }; // expected-note{{template is declared here}}
void f(void) { Foo bar; } // expected-error{{without a template argument list}}
+
+// rdar://problem/8254267
+template <typename T> class Party;
+template <> class Party<T> { friend struct Party<>; }; // expected-error {{use of undeclared identifier 'T'}}
Modified: cfe/trunk/test/SemaTemplate/deduction-crash.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/deduction-crash.cpp?rev=109853&r1=109852&r2=109853&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/deduction-crash.cpp (original)
+++ cfe/trunk/test/SemaTemplate/deduction-crash.cpp Fri Jul 30 01:26:29 2010
@@ -4,7 +4,7 @@
// Note that the error count below doesn't matter. We just want to
// make sure that the parser doesn't crash.
-// CHECK: 16 errors
+// CHECK: 15 errors
template<a>
struct int_;
More information about the cfe-commits
mailing list