forked from OSchip/llvm-project
				
			When creating an implicit conversion sequence for a reference of type T from an
initializer list containing a single element of type T, be sure to mark the sequence as a list conversion sequence so that it is known to be worse than an implicit conversion sequence that initializes a std::initializer_list object. llvm-svn: 190115
This commit is contained in:
		
							parent
							
								
									bc8c734fa7
								
							
						
					
					
						commit
						4d2bbd78ff
					
				| 
						 | 
				
			
			@ -509,6 +509,11 @@ void UserDefinedConversionSequence::DebugPrint() const {
 | 
			
		|||
/// error. Useful for debugging overloading issues.
 | 
			
		||||
void ImplicitConversionSequence::DebugPrint() const {
 | 
			
		||||
  raw_ostream &OS = llvm::errs();
 | 
			
		||||
  if (isListInitializationSequence()) {
 | 
			
		||||
    OS << "List-initialization sequence: ";
 | 
			
		||||
    if (isStdInitializerListElement())
 | 
			
		||||
      OS << "Worst std::initializer_list element conversion: ";
 | 
			
		||||
  }
 | 
			
		||||
  switch (ConversionKind) {
 | 
			
		||||
  case StandardConversion:
 | 
			
		||||
    OS << "Standard conversion: ";
 | 
			
		||||
| 
						 | 
				
			
			@ -4524,11 +4529,13 @@ TryListConversion(Sema &S, InitListExpr *From, QualType ToType,
 | 
			
		|||
        = S.CompareReferenceRelationship(From->getLocStart(), T1, T2, dummy1,
 | 
			
		||||
                                         dummy2, dummy3);
 | 
			
		||||
 | 
			
		||||
      if (RefRelationship >= Sema::Ref_Related)
 | 
			
		||||
        return TryReferenceInit(S, Init, ToType,
 | 
			
		||||
                                /*FIXME:*/From->getLocStart(),
 | 
			
		||||
                                SuppressUserConversions,
 | 
			
		||||
                                /*AllowExplicit=*/false);
 | 
			
		||||
      if (RefRelationship >= Sema::Ref_Related) {
 | 
			
		||||
        Result = TryReferenceInit(S, Init, ToType, /*FIXME*/From->getLocStart(),
 | 
			
		||||
                                  SuppressUserConversions,
 | 
			
		||||
                                  /*AllowExplicit=*/false);
 | 
			
		||||
        Result.setListInitializationSequence();
 | 
			
		||||
        return Result;
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Otherwise, we bind the reference to a temporary created from the
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -218,3 +218,10 @@ namespace deleted_copy {
 | 
			
		|||
 | 
			
		||||
  std::initializer_list<X> x{1}; // expected-error {{invokes deleted constructor}}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
namespace RefVersusInitList {
 | 
			
		||||
  struct S {};
 | 
			
		||||
  void f(const S &) = delete;
 | 
			
		||||
  void f(std::initializer_list<S>);
 | 
			
		||||
  void g(S s) { f({S()}); }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue