[cfe-commits] r113796 - in /cfe/trunk: lib/Sema/SemaExprCXX.cpp test/SemaCXX/type-traits.cpp
Sebastian Redl
sebastian.redl at getdesigned.at
Mon Sep 13 15:18:29 PDT 2010
Author: cornedbee
Date: Mon Sep 13 17:18:28 2010
New Revision: 113796
URL: http://llvm.org/viewvc/llvm-project?rev=113796&view=rev
Log:
Don't crash when using type traits on a class with a constructor template.
Modified:
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/test/SemaCXX/type-traits.cpp
Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=113796&r1=113795&r2=113796&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Mon Sep 13 17:18:28 2010
@@ -2148,6 +2148,11 @@
DeclContext::lookup_const_iterator Con, ConEnd;
for (llvm::tie(Con, ConEnd) = Self.LookupConstructors(RD);
Con != ConEnd; ++Con) {
+ // A template constructor is never a copy constructor.
+ // FIXME: However, it may actually be selected at the actual overload
+ // resolution point.
+ if (isa<FunctionTemplateDecl>(*Con))
+ continue;
CXXConstructorDecl *Constructor = cast<CXXConstructorDecl>(*Con);
if (Constructor->isCopyConstructor(FoundTQs)) {
FoundConstructor = true;
@@ -2181,6 +2186,9 @@
DeclContext::lookup_const_iterator Con, ConEnd;
for (llvm::tie(Con, ConEnd) = Self.LookupConstructors(RD);
Con != ConEnd; ++Con) {
+ // FIXME: In C++0x, a constructor template can be a default constructor.
+ if (isa<FunctionTemplateDecl>(*Con))
+ continue;
CXXConstructorDecl *Constructor = cast<CXXConstructorDecl>(*Con);
if (Constructor->isDefaultConstructor()) {
const FunctionProtoType *CPT
Modified: cfe/trunk/test/SemaCXX/type-traits.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/type-traits.cpp?rev=113796&r1=113795&r2=113796&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/type-traits.cpp (original)
+++ cfe/trunk/test/SemaCXX/type-traits.cpp Mon Sep 13 17:18:28 2010
@@ -215,6 +215,13 @@
HasCopy(HasCopy& cp);
};
+struct HasTemplateCons {
+ HasVirt Annoying;
+
+ template <typename T>
+ HasTemplateCons(const T&);
+};
+
void has_trivial_default_constructor() {
int t01[T(__has_trivial_constructor(Int))];
int t02[T(__has_trivial_constructor(IntAr))];
@@ -236,6 +243,7 @@
int t18[F(__has_trivial_constructor(VirtAr))];
int t19[F(__has_trivial_constructor(void))];
int t20[F(__has_trivial_constructor(cvoid))];
+ int t21[F(__has_trivial_constructor(HasTemplateCons))];
}
void has_trivial_copy_constructor() {
@@ -259,6 +267,7 @@
int t18[F(__has_trivial_copy(VirtAr))];
int t19[F(__has_trivial_copy(void))];
int t20[F(__has_trivial_copy(cvoid))];
+ int t21[F(__has_trivial_copy(HasTemplateCons))];
}
void has_trivial_copy_assignment() {
@@ -367,6 +376,7 @@
int t22[F(__has_nothrow_copy(void))];
int t23[F(__has_nothrow_copy(cvoid))];
int t24[T(__has_nothrow_copy(HasVirtDest))];
+ int t25[T(__has_nothrow_copy(HasTemplateCons))];
}
void has_nothrow_constructor() {
@@ -394,6 +404,7 @@
int t21[F(__has_nothrow_constructor(void))];
int t22[F(__has_nothrow_constructor(cvoid))];
int t23[T(__has_nothrow_constructor(HasVirtDest))];
+ int t24[F(__has_nothrow_constructor(HasTemplateCons))];
}
void has_virtual_destructor() {
More information about the cfe-commits
mailing list