summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-12-23 22:44:42 +0000
committerDouglas Gregor <dgregor@apple.com>2010-12-23 22:44:42 +0000
commit27b4c16fefde48966b65f878799e9a7792275675 (patch)
tree720bde9e2688238bfbd9fee94671d1d4b4af93f4 /clang/lib/Sema/SemaDecl.cpp
parent1d56c9eed77fe703f389bfa82f79b155a30168d4 (diff)
downloadbcm5719-llvm-27b4c16fefde48966b65f878799e9a7792275675.tar.gz
bcm5719-llvm-27b4c16fefde48966b65f878799e9a7792275675.zip
Implement parsing of function parameter packs and non-type template
parameter packs (C++0x [dcl.fct]p13), including disambiguation between unnamed function parameter packs and varargs (C++0x [dcl.fct]p14) for cases like void f(T...) where T may or may not contain unexpanded parameter packs. llvm-svn: 122520
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp41
1 files changed, 24 insertions, 17 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 890399c4282..d5966494790 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -4959,20 +4959,34 @@ Decl *Sema::ActOnParamDeclarator(Scope *S, Declarator &D) {
DiagnoseFunctionSpecifiers(D);
- // Check that there are no default arguments inside the type of this
- // parameter (C++ only).
- if (getLangOptions().CPlusPlus)
- CheckExtraCXXDefaultArguments(D);
-
TagDecl *OwnedDecl = 0;
TypeSourceInfo *TInfo = GetTypeForDeclarator(D, S, &OwnedDecl);
QualType parmDeclType = TInfo->getType();
- if (getLangOptions().CPlusPlus && OwnedDecl && OwnedDecl->isDefinition()) {
- // C++ [dcl.fct]p6:
- // Types shall not be defined in return or parameter types.
- Diag(OwnedDecl->getLocation(), diag::err_type_defined_in_param_type)
- << Context.getTypeDeclType(OwnedDecl);
+ if (getLangOptions().CPlusPlus) {
+ // Check that there are no default arguments inside the type of this
+ // parameter.
+ CheckExtraCXXDefaultArguments(D);
+
+ if (OwnedDecl && OwnedDecl->isDefinition()) {
+ // C++ [dcl.fct]p6:
+ // Types shall not be defined in return or parameter types.
+ Diag(OwnedDecl->getLocation(), diag::err_type_defined_in_param_type)
+ << Context.getTypeDeclType(OwnedDecl);
+ }
+
+ // Parameter declarators cannot be qualified (C++ [dcl.meaning]p1).
+ if (D.getCXXScopeSpec().isSet()) {
+ Diag(D.getIdentifierLoc(), diag::err_qualified_param_declarator)
+ << D.getCXXScopeSpec().getRange();
+ D.getCXXScopeSpec().clear();
+ }
+
+ // FIXME: Variadic templates.
+ if (D.hasEllipsis()) {
+ Diag(D.getEllipsisLoc(), diag::err_function_parameter_pack_unsupported);
+ D.setInvalidType();
+ }
}
// Ensure we have a valid name
@@ -5021,13 +5035,6 @@ Decl *Sema::ActOnParamDeclarator(Scope *S, Declarator &D) {
if (D.isInvalidType())
New->setInvalidDecl();
- // Parameter declarators cannot be qualified (C++ [dcl.meaning]p1).
- if (D.getCXXScopeSpec().isSet()) {
- Diag(D.getIdentifierLoc(), diag::err_qualified_param_declarator)
- << D.getCXXScopeSpec().getRange();
- New->setInvalidDecl();
- }
-
// Add the parameter declaration into this scope.
S->AddDecl(New);
if (II)
OpenPOWER on IntegriCloud