[cfe-commits] r80421 - in /cfe/trunk: lib/Parse/ParseExprCXX.cpp test/SemaCXX/invalid-template-specifier.cpp
Eli Friedman
eli.friedman at gmail.com
Fri Aug 28 21:08:09 PDT 2009
Author: efriedma
Date: Fri Aug 28 23:08:08 2009
New Revision: 80421
URL: http://llvm.org/viewvc/llvm-project?rev=80421&view=rev
Log:
Fix a couple issues with parsing invalid nested-name-specifiers.
Added:
cfe/trunk/test/SemaCXX/invalid-template-specifier.cpp
Modified:
cfe/trunk/lib/Parse/ParseExprCXX.cpp
Modified: cfe/trunk/lib/Parse/ParseExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExprCXX.cpp?rev=80421&r1=80420&r2=80421&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseExprCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExprCXX.cpp Fri Aug 28 23:08:08 2009
@@ -65,6 +65,12 @@
// Parse the optional 'template' keyword, then make sure we have
// 'identifier <' after it.
if (Tok.is(tok::kw_template)) {
+ // If we don't have a scope specifier, this isn't a
+ // nested-name-specifier, since they aren't allowed to start with
+ // 'template'.
+ if (!HasScopeSpecifier)
+ break;
+
SourceLocation TemplateKWLoc = ConsumeToken();
if (Tok.isNot(tok::identifier)) {
@@ -86,6 +92,8 @@
= Actions.ActOnDependentTemplateName(TemplateKWLoc,
*Tok.getIdentifierInfo(),
Tok.getLocation(), SS);
+ if (!Template)
+ break;
if (AnnotateTemplateIdToken(Template, TNK_Dependent_template_name,
&SS, TemplateKWLoc, false))
break;
Added: cfe/trunk/test/SemaCXX/invalid-template-specifier.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/invalid-template-specifier.cpp?rev=80421&view=auto
==============================================================================
--- cfe/trunk/test/SemaCXX/invalid-template-specifier.cpp (added)
+++ cfe/trunk/test/SemaCXX/invalid-template-specifier.cpp Fri Aug 28 23:08:08 2009
@@ -0,0 +1,12 @@
+// RUN: clang-cc %s -verify -fsyntax-only
+// PR4809
+// This test is primarily checking that this doesn't crash, not the particular
+// diagnostics.
+
+const template basic_istream<char>; // expected-error {{expected unqualified-id}}
+
+namespace S {}
+template <class X> class Y {
+ void x() { S::template y<char>(1); } // expected-error {{does not refer to a template}} \
+ // expected-error {{no member named 'y'}}
+};
More information about the cfe-commits
mailing list