[cfe-commits] r73267 - in /cfe/trunk: include/clang/Basic/DiagnosticParseKinds.td lib/Parse/ParseTemplate.cpp test/SemaTemplate/variadic-unsupported.cpp
Anders Carlsson
andersca at mac.com
Fri Jun 12 16:09:56 PDT 2009
Author: andersca
Date: Fri Jun 12 18:09:56 2009
New Revision: 73267
URL: http://llvm.org/viewvc/llvm-project?rev=73267&view=rev
Log:
Address more comments from Doug.
Added:
cfe/trunk/test/SemaTemplate/variadic-unsupported.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/lib/Parse/ParseTemplate.cpp
Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=73267&r1=73266&r2=73267&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Fri Jun 12 18:09:56 2009
@@ -256,6 +256,9 @@
def err_expected_type_name_after_typename : Error<
"expected an identifier or template-id after '::'">;
+def err_variadic_templates : Error<
+ "variadic templates are only allowed in C++0x">;
+
// Language specific pragmas
// - Generic warnings
def warn_pragma_expected_lparen : Warning<
Modified: cfe/trunk/lib/Parse/ParseTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseTemplate.cpp?rev=73267&r1=73266&r2=73267&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseTemplate.cpp (original)
+++ cfe/trunk/lib/Parse/ParseTemplate.cpp Fri Jun 12 18:09:56 2009
@@ -290,11 +290,11 @@
/// parameter-declaration
///
/// type-parameter: (see below)
-/// 'class' ...[opt] identifier[opt]
+/// 'class' ...[opt][C++0x] identifier[opt]
/// 'class' identifier[opt] '=' type-id
-/// 'typename' ...[opt] identifier[opt]
+/// 'typename' ...[opt][C++0x] identifier[opt]
/// 'typename' identifier[opt] '=' type-id
-/// 'template' ...[opt] '<' template-parameter-list '>' 'class' identifier[opt]
+/// 'template' ...[opt][C++0x] '<' template-parameter-list '>' 'class' identifier[opt]
/// 'template' '<' template-parameter-list '>' 'class' identifier[opt] = id-expression
Parser::DeclPtrTy
Parser::ParseTemplateParameter(unsigned Depth, unsigned Position) {
@@ -319,9 +319,9 @@
/// ParseTemplateTemplateParameter and ParseNonTypeTemplateParameter.
///
/// type-parameter: [C++ temp.param]
-/// 'class' ...[opt] identifier[opt]
+/// 'class' ...[opt][C++0x] identifier[opt]
/// 'class' identifier[opt] '=' type-id
-/// 'typename' ...[opt] identifier[opt]
+/// 'typename' ...[opt][C++0x] identifier[opt]
/// 'typename' identifier[opt] '=' type-id
Parser::DeclPtrTy Parser::ParseTypeParameter(unsigned Depth, unsigned Position){
assert((Tok.is(tok::kw_class) || Tok.is(tok::kw_typename)) &&
@@ -334,9 +334,12 @@
// Grab the ellipsis (if given).
bool Ellipsis = false;
SourceLocation EllipsisLoc;
- if (getLang().CPlusPlus0x && Tok.is(tok::ellipsis)) {
+ if (Tok.is(tok::ellipsis)) {
Ellipsis = true;
EllipsisLoc = ConsumeToken();
+
+ if (!getLang().CPlusPlus0x)
+ Diag(EllipsisLoc, diag::err_variadic_templates);
}
// Grab the template parameter name (if given)
Added: cfe/trunk/test/SemaTemplate/variadic-unsupported.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/variadic-unsupported.cpp?rev=73267&view=auto
==============================================================================
--- cfe/trunk/test/SemaTemplate/variadic-unsupported.cpp (added)
+++ cfe/trunk/test/SemaTemplate/variadic-unsupported.cpp Fri Jun 12 18:09:56 2009
@@ -0,0 +1,5 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+// Type parameter packs.
+template <typename ... > struct T1 {}; // expected-error{{variadic templates are only allowed in C++0x}}
+
More information about the cfe-commits
mailing list