[cfe-commits] r153130 - in /cfe/trunk: lib/Sema/SemaOverload.cpp test/SemaCXX/cxx0x-initializer-constructor.cpp
Sebastian Redl
sebastian.redl at getdesigned.at
Tue Mar 20 14:24:15 PDT 2012
Author: cornedbee
Date: Tue Mar 20 16:24:14 2012
New Revision: 153130
URL: http://llvm.org/viewvc/llvm-project?rev=153130&view=rev
Log:
More careful consideration of C++11 13.3.3.1p4. Fixes PR12257.
Modified:
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/test/SemaCXX/cxx0x-initializer-constructor.cpp
Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=153130&r1=153129&r2=153130&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Tue Mar 20 16:24:14 2012
@@ -2904,22 +2904,34 @@
else
Usable = Usable &&Constructor->isConvertingConstructor(AllowExplicit);
if (Usable) {
+ bool SuppressUserConversions = !ConstructorsOnly;
+ if (SuppressUserConversions && ListInitializing) {
+ SuppressUserConversions = false;
+ if (NumArgs == 1) {
+ // If the first argument is (a reference to) the target type,
+ // suppress conversions.
+ const FunctionProtoType *CtorType =
+ Constructor->getType()->getAs<FunctionProtoType>();
+ if (CtorType->getNumArgs() > 0) {
+ QualType FirstArg = CtorType->getArgType(0);
+ if (S.Context.hasSameUnqualifiedType(ToType,
+ FirstArg.getNonReferenceType())) {
+ SuppressUserConversions = true;
+ }
+ }
+ }
+ }
if (ConstructorTmpl)
S.AddTemplateOverloadCandidate(ConstructorTmpl, FoundDecl,
/*ExplicitArgs*/ 0,
llvm::makeArrayRef(Args, NumArgs),
- CandidateSet,
- /*SuppressUserConversions=*/
- !ConstructorsOnly &&
- !ListInitializing);
+ CandidateSet, SuppressUserConversions);
else
// Allow one user-defined conversion when user specifies a
// From->ToType conversion via an static cast (c-style, etc).
S.AddOverloadCandidate(Constructor, FoundDecl,
llvm::makeArrayRef(Args, NumArgs),
- CandidateSet,
- /*SuppressUserConversions=*/
- !ConstructorsOnly && !ListInitializing);
+ CandidateSet, SuppressUserConversions);
}
}
}
Modified: cfe/trunk/test/SemaCXX/cxx0x-initializer-constructor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx0x-initializer-constructor.cpp?rev=153130&r1=153129&r2=153130&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/cxx0x-initializer-constructor.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx0x-initializer-constructor.cpp Tue Mar 20 16:24:14 2012
@@ -236,3 +236,31 @@
bool s = f(string<1>());
}
+
+namespace PR12257 {
+ struct command_pair
+ {
+ command_pair(int, int);
+ };
+
+ struct command_map
+ {
+ command_map(std::initializer_list<command_pair>);
+ };
+
+ struct generator_pair
+ {
+ generator_pair(const command_map);
+ };
+
+ const std::initializer_list<generator_pair> x =
+ {
+ {
+ {
+ {
+ {3, 4}
+ }
+ }
+ }
+ };
+}
More information about the cfe-commits
mailing list