aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2009-12-11 02:42:07 +0000
committerEli Friedman <eli.friedman@gmail.com>2009-12-11 02:42:07 +0000
commit03981014e4f0c3b4e935872dda96a28c2f1874ea (patch)
tree98eeb16d651eae55f031af62afba82b528c58840
parentd7533ec10b618d360eb8952e62edb5657199acd3 (diff)
Fix a recent regression from the initialization changes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91097 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Sema/SemaInit.cpp21
-rw-r--r--lib/Sema/SemaInit.h2
-rw-r--r--test/CodeGenCXX/reference-init.cpp9
3 files changed, 22 insertions, 10 deletions
diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp
index 08ae7cbfbe..a1fd79b852 100644
--- a/lib/Sema/SemaInit.cpp
+++ b/lib/Sema/SemaInit.cpp
@@ -2001,10 +2001,11 @@ void InitializationSequence::AddReferenceBindingStep(QualType T,
Steps.push_back(S);
}
-void InitializationSequence::AddUserConversionStep(FunctionDecl *Function) {
+void InitializationSequence::AddUserConversionStep(FunctionDecl *Function,
+ QualType T) {
Step S;
S.Kind = SK_UserConversion;
- S.Type = Function->getResultType().getNonReferenceType();
+ S.Type = T;
S.Function = Function;
Steps.push_back(S);
}
@@ -2209,18 +2210,20 @@ static OverloadingResult TryRefInitWithConversionFunction(Sema &S,
if (OverloadingResult Result
= S.BestViableFunction(CandidateSet, DeclLoc, Best))
return Result;
-
- // Add the user-defined conversion step.
+
FunctionDecl *Function = Best->Function;
- Sequence.AddUserConversionStep(Function);
-
- // Determine whether we need to perform derived-to-base or
- // cv-qualification adjustments.
+
+ // Compute the returned type of the conversion.
if (isa<CXXConversionDecl>(Function))
T2 = Function->getResultType();
else
T2 = cv1T1;
-
+
+ // Add the user-defined conversion step.
+ Sequence.AddUserConversionStep(Function, T2.getNonReferenceType());
+
+ // Determine whether we need to perform derived-to-base or
+ // cv-qualification adjustments.
bool NewDerivedToBase = false;
Sema::ReferenceCompareResult NewRefRelationship
= S.CompareReferenceRelationship(DeclLoc, T1, T2.getNonReferenceType(),
diff --git a/lib/Sema/SemaInit.h b/lib/Sema/SemaInit.h
index debb0deadd..a29159ace5 100644
--- a/lib/Sema/SemaInit.h
+++ b/lib/Sema/SemaInit.h
@@ -511,7 +511,7 @@ public:
/// \brief Add a new step invoking a conversion function, which is either
/// a constructor or a conversion function.
- void AddUserConversionStep(FunctionDecl *Function);
+ void AddUserConversionStep(FunctionDecl *Function, QualType T);
/// \brief Add a new step that performs a qualification conversion to the
/// given type.
diff --git a/test/CodeGenCXX/reference-init.cpp b/test/CodeGenCXX/reference-init.cpp
new file mode 100644
index 0000000000..9baad94a96
--- /dev/null
+++ b/test/CodeGenCXX/reference-init.cpp
@@ -0,0 +1,9 @@
+// RUN: clang-cc -emit-llvm-only -verify %s
+
+struct XPTParamDescriptor {};
+struct nsXPTParamInfo {
+ nsXPTParamInfo(const XPTParamDescriptor& desc);
+};
+void a(XPTParamDescriptor *params) {
+ const nsXPTParamInfo& paramInfo = params[0];
+}