diff options
author | Anders Carlsson <andersca@mac.com> | 2009-06-12 23:09:56 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2009-06-12 23:09:56 +0000 |
commit | ce5635a1008b3aedaecb1a3b29bb77e1b71080d1 (patch) | |
tree | 77c2e2f59e64c4a996b64f80f859607460842b20 | |
parent | 989135901c750af61ef012b6b0a0368be415bc46 (diff) |
Address more comments from Doug.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73267 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/Basic/DiagnosticParseKinds.td | 3 | ||||
-rw-r--r-- | lib/Parse/ParseTemplate.cpp | 15 | ||||
-rw-r--r-- | test/SemaTemplate/variadic-unsupported.cpp | 5 |
3 files changed, 17 insertions, 6 deletions
diff --git a/include/clang/Basic/DiagnosticParseKinds.td b/include/clang/Basic/DiagnosticParseKinds.td index 81afac9a60..b681b7d271 100644 --- a/include/clang/Basic/DiagnosticParseKinds.td +++ b/include/clang/Basic/DiagnosticParseKinds.td @@ -256,6 +256,9 @@ def err_typename_refers_to_non_type_template : Error< 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< diff --git a/lib/Parse/ParseTemplate.cpp b/lib/Parse/ParseTemplate.cpp index 30924b217f..a9f75d8be1 100644 --- a/lib/Parse/ParseTemplate.cpp +++ b/lib/Parse/ParseTemplate.cpp @@ -290,11 +290,11 @@ Parser::ParseTemplateParameterList(unsigned Depth, /// 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 @@ Parser::ParseTemplateParameter(unsigned Depth, unsigned Position) { /// 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 @@ Parser::DeclPtrTy Parser::ParseTypeParameter(unsigned Depth, unsigned Position){ // 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) diff --git a/test/SemaTemplate/variadic-unsupported.cpp b/test/SemaTemplate/variadic-unsupported.cpp new file mode 100644 index 0000000000..98f217c768 --- /dev/null +++ b/test/SemaTemplate/variadic-unsupported.cpp @@ -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}} + |