[cfe-commits] r92177 - in /cfe/trunk: lib/Parse/ParseTemplate.cpp test/Parser/cxx-template-argument.cpp
Eli Friedman
eli.friedman at gmail.com
Sun Dec 27 14:31:18 PST 2009
Author: efriedma
Date: Sun Dec 27 16:31:18 2009
New Revision: 92177
URL: http://llvm.org/viewvc/llvm-project?rev=92177&view=rev
Log:
Make sure to give an error for template argument lists followed by junk.
Added:
cfe/trunk/test/Parser/cxx-template-argument.cpp
Modified:
cfe/trunk/lib/Parse/ParseTemplate.cpp
Modified: cfe/trunk/lib/Parse/ParseTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseTemplate.cpp?rev=92177&r1=92176&r2=92177&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseTemplate.cpp (original)
+++ cfe/trunk/lib/Parse/ParseTemplate.cpp Sun Dec 27 16:31:18 2009
@@ -643,8 +643,10 @@
}
}
- if (Tok.isNot(tok::greater) && Tok.isNot(tok::greatergreater))
+ if (Tok.isNot(tok::greater) && Tok.isNot(tok::greatergreater)) {
+ Diag(Tok.getLocation(), diag::err_expected_greater);
return true;
+ }
// Determine the location of the '>' or '>>'. Only consume this
// token if the caller asked us to.
@@ -989,7 +991,7 @@
ConsumeToken();
}
- return Tok.isNot(tok::greater) && Tok.isNot(tok::greatergreater);
+ return false;
}
/// \brief Parse a C++ explicit template instantiation
Added: cfe/trunk/test/Parser/cxx-template-argument.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx-template-argument.cpp?rev=92177&view=auto
==============================================================================
--- cfe/trunk/test/Parser/cxx-template-argument.cpp (added)
+++ cfe/trunk/test/Parser/cxx-template-argument.cpp Sun Dec 27 16:31:18 2009
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template<typename T> struct A {};
+
+// Check for template argument lists followed by junk
+// FIXME: The diagnostics here aren't great...
+A<int+> int x; // expected-error {{expected '>'}} expected-error {{expected unqualified-id}}
+A<int x; // expected-error {{expected '>'}} expected-error {{C++ requires a type specifier for all declarations}}
+
More information about the cfe-commits
mailing list