summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
Diffstat (limited to 'clang')
-rw-r--r--clang/include/clang/Basic/DiagnosticSemaKinds.td20
-rw-r--r--clang/include/clang/Sema/Sema.h12
-rw-r--r--clang/lib/AST/Type.cpp9
-rw-r--r--clang/lib/Sema/SemaDecl.cpp14
-rw-r--r--clang/test/CXX/temp/temp.decls/temp.variadic/p5.cpp15
5 files changed, 58 insertions, 12 deletions
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 787a9b5aad3..78a7a17eb5e 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1822,17 +1822,21 @@ def note_template_parameter_pack_here : Note<
"parameter%select{| pack}1 declared here">;
def err_unexpanded_parameter_pack_0 : Error<
- "%select{expression|base type|declaration type|template argument}0 contains "
- "unexpanded parameter pack">;
+ "%select{expression|base type|declaration type|data member type|bit-field "
+ "size}0 "
+ "contains unexpanded parameter pack">;
def err_unexpanded_parameter_pack_1 : Error<
- "%select{expression|base type|declaration type|template argument}0 contains "
- "unexpanded parameter pack %1">;
+ "%select{expression|base type|declaration type|data member type|bit-field "
+ "size}0 "
+ "contains unexpanded parameter pack %1">;
def err_unexpanded_parameter_pack_2 : Error<
- "%select{expression|base type|declaration type|template argument}0 contains "
- "unexpanded parameter packs %1 and %2">;
+ "%select{expression|base type|declaration type|data member type|bit-field "
+ "size}0 "
+ "contains unexpanded parameter packs %1 and %2">;
def err_unexpanded_parameter_pack_3_or_more : Error<
- "%select{expression|base type|declaration type|template argument}0 contains "
- "unexpanded parameter packs %1, %2, ...">;
+ "%select{expression|base type|declaration type|data member type|bit-field "
+ "size}0 "
+ "contains unexpanded parameter packs %1, %2, ...">;
def err_unexpected_typedef : Error<
"unexpected type name %0: expected expression">;
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 22e395cf961..2dc09d339c4 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -3135,10 +3135,20 @@ public:
/// Note that the values of this enumeration line up with the first
/// argument to the \c err_unexpanded_parameter_pack diagnostic.
enum UnexpandedParameterPackContext {
+ /// \brief An arbitrary expression.
UPPC_Expression = 0,
+
+ /// \brief The base type of a class type.
UPPC_BaseType,
+
+ /// \brief The type of an arbitrary declaration.
UPPC_DeclarationType,
- UPPC_TemplateArgument
+
+ /// \brief The type of a data member.
+ UPPC_DataMemberType,
+
+ /// \brief The size of a bit-field.
+ UPPC_BitFieldWidth
};
/// \brief If the given type contains an unexpanded parameter pack,
diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index 0991e5a7093..9dbbfaa733d 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -1123,8 +1123,15 @@ FunctionProtoType::FunctionProtoType(QualType result, const QualType *args,
// Fill in the exception array.
QualType *exnSlot = argSlot + numArgs;
- for (unsigned i = 0, e = epi.NumExceptions; i != e; ++i)
+ for (unsigned i = 0, e = epi.NumExceptions; i != e; ++i) {
+ if (epi.Exceptions[i]->isDependentType())
+ setDependent();
+
+ if (epi.Exceptions[i]->containsUnexpandedParameterPack())
+ setContainsUnexpandedParameterPack();
+
exnSlot[i] = epi.Exceptions[i];
+ }
}
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 6182e8663b4..5704cb5ad46 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -6424,7 +6424,9 @@ bool Sema::VerifyBitField(SourceLocation FieldLoc, IdentifierInfo *FieldName,
<< FieldName << FieldTy << BitWidth->getSourceRange();
return Diag(FieldLoc, diag::err_not_integral_type_anon_bitfield)
<< FieldTy << BitWidth->getSourceRange();
- }
+ } else if (DiagnoseUnexpandedParameterPack(const_cast<Expr *>(BitWidth),
+ UPPC_BitFieldWidth))
+ return true;
// If the bit-width is type- or value-dependent, don't try to check
// it now.
@@ -6499,9 +6501,17 @@ FieldDecl *Sema::HandleField(Scope *S, RecordDecl *Record,
TypeSourceInfo *TInfo = GetTypeForDeclarator(D, S);
QualType T = TInfo->getType();
- if (getLangOptions().CPlusPlus)
+ if (getLangOptions().CPlusPlus) {
CheckExtraCXXDefaultArguments(D);
+ if (DiagnoseUnexpandedParameterPack(D.getIdentifierLoc(), TInfo,
+ UPPC_DataMemberType)) {
+ D.setInvalidType();
+ T = Context.IntTy;
+ TInfo = Context.getTrivialTypeSourceInfo(T, Loc);
+ }
+ }
+
DiagnoseFunctionSpecifiers(D);
if (D.getDeclSpec().isThreadSpecified())
diff --git a/clang/test/CXX/temp/temp.decls/temp.variadic/p5.cpp b/clang/test/CXX/temp/temp.decls/temp.variadic/p5.cpp
index 760dc342db0..0e5c9c09798 100644
--- a/clang/test/CXX/temp/temp.decls/temp.variadic/p5.cpp
+++ b/clang/test/CXX/temp/temp.decls/temp.variadic/p5.cpp
@@ -96,11 +96,25 @@ struct TestPPName
// ObjCObjectPointerType is uninteresting
};
+// FIXME: Test for unexpanded parameter packs in each of the expression nodes.
+
template<typename ... Types>
void TestPPNameFunc(int i) {
f(static_cast<Types>(i)); // expected-error{{expression contains unexpanded parameter pack 'Types'}}
}
+// FIXME: Test for unexpanded parameter packs in declarations.
+template<typename... Types>
+struct TestUnexpandedDecls {
+ void member_function(Types); // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
+ void member_function () throw(Types); // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
+ Types data_member; // expected-error{{data member type contains unexpanded parameter pack 'Types'}}
+ static Types static_data_member; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
+ unsigned bit_field : static_cast<Types>(0); // expected-error{{bit-field size contains unexpanded parameter pack 'Types'}}
+};
+
+// Test for diagnostics in the presence of multiple unexpanded
+// parameter packs.
template<typename T, typename U> struct pair;
template<typename ...OuterTypes>
@@ -115,3 +129,4 @@ struct MemberTemplatePPNames {
};
};
};
+
OpenPOWER on IntegriCloud