[cfe-commits] r80377 - in /cfe/trunk: include/clang/AST/DeclCXX.h lib/AST/DeclCXX.cpp lib/Sema/SemaDeclCXX.cpp lib/Sema/SemaOverload.cpp test/SemaCXX/cast-explicit-ctor.cpp
Anders Carlsson
andersca at mac.com
Fri Aug 28 09:57:08 PDT 2009
Author: andersca
Date: Fri Aug 28 11:57:08 2009
New Revision: 80377
URL: http://llvm.org/viewvc/llvm-project?rev=80377&view=rev
Log:
Fix this for real.
Modified:
cfe/trunk/include/clang/AST/DeclCXX.h
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/test/SemaCXX/cast-explicit-ctor.cpp
Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=80377&r1=80376&r2=80377&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Fri Aug 28 11:57:08 2009
@@ -1068,7 +1068,7 @@
/// isConvertingConstructor - Whether this constructor is a
/// converting constructor (C++ [class.conv.ctor]), which can be
/// used for user-defined conversions.
- bool isConvertingConstructor() const;
+ bool isConvertingConstructor(bool AllowExplicit) const;
// Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) {
Modified: cfe/trunk/lib/AST/DeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=80377&r1=80376&r2=80377&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclCXX.cpp (original)
+++ cfe/trunk/lib/AST/DeclCXX.cpp Fri Aug 28 11:57:08 2009
@@ -489,14 +489,14 @@
return true;
}
-bool CXXConstructorDecl::isConvertingConstructor() const {
+bool CXXConstructorDecl::isConvertingConstructor(bool AllowExplicit) const {
// C++ [class.conv.ctor]p1:
// A constructor declared without the function-specifier explicit
// that can be called with a single parameter specifies a
// conversion from the type of its first parameter to the type of
// its class. Such a constructor is called a converting
// constructor.
- if (isExplicit())
+ if (isExplicit() && !AllowExplicit)
return false;
return (getNumParams() == 0 &&
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=80377&r1=80376&r2=80377&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Fri Aug 28 11:57:08 2009
@@ -2785,7 +2785,8 @@
Constructor = cast<CXXConstructorDecl>(*Con);
if ((Kind == IK_Direct) ||
- (Kind == IK_Copy && Constructor->isConvertingConstructor()) ||
+ (Kind == IK_Copy &&
+ Constructor->isConvertingConstructor(/*AllowExplicit=*/false)) ||
(Kind == IK_Default && Constructor->isDefaultConstructor())) {
if (ConstructorTmpl)
AddTemplateOverloadCandidate(ConstructorTmpl, false, 0, 0,
Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=80377&r1=80376&r2=80377&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Fri Aug 28 11:57:08 2009
@@ -1394,7 +1394,7 @@
Constructor = cast<CXXConstructorDecl>(*Con);
if (!Constructor->isInvalidDecl() &&
- Constructor->isConvertingConstructor()) {
+ Constructor->isConvertingConstructor(AllowExplicit)) {
if (ConstructorTmpl)
AddTemplateOverloadCandidate(ConstructorTmpl, false, 0, 0, &From,
1, CandidateSet,
Modified: cfe/trunk/test/SemaCXX/cast-explicit-ctor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cast-explicit-ctor.cpp?rev=80377&r1=80376&r2=80377&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/cast-explicit-ctor.cpp (original)
+++ cfe/trunk/test/SemaCXX/cast-explicit-ctor.cpp Fri Aug 28 11:57:08 2009
@@ -1,5 +1,5 @@
// RUN: clang-cc -fsyntax-only -verify %s
-struct B { B(bool); };
+struct B { explicit B(bool); };
void f() {
(void)(B)true;
(void)B(true);
More information about the cfe-commits
mailing list