[llvm-branch-commits] [cfe-branch] r118569 - in /cfe/branches/Apple/whitney: lib/Sema/SemaInit.cpp test/SemaCXX/addr-of-overloaded-function.cpp
Daniel Dunbar
daniel at zuster.org
Tue Nov 9 09:32:22 PST 2010
Author: ddunbar
Date: Tue Nov 9 11:32:22 2010
New Revision: 118569
URL: http://llvm.org/viewvc/llvm-project?rev=118569&view=rev
Log:
Merge r118407:
--
Author: Douglas Gregor <dgregor at apple.com>
Date: Mon Nov 8 15:20:28 2010 +0000
When attempting reference binding to an overloaded function, also
consider that we might be trying to bind a reference to a class type,
which involves a constructor call. Fixes PR7425.
Modified:
cfe/branches/Apple/whitney/lib/Sema/SemaInit.cpp
cfe/branches/Apple/whitney/test/SemaCXX/addr-of-overloaded-function.cpp
Modified: cfe/branches/Apple/whitney/lib/Sema/SemaInit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/lib/Sema/SemaInit.cpp?rev=118569&r1=118568&r2=118569&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/lib/Sema/SemaInit.cpp (original)
+++ cfe/branches/Apple/whitney/lib/Sema/SemaInit.cpp Tue Nov 9 11:32:22 2010
@@ -2511,18 +2511,17 @@
// type of the resulting function.
if (S.Context.getCanonicalType(T2) == S.Context.OverloadTy) {
DeclAccessPair Found;
- FunctionDecl *Fn = S.ResolveAddressOfOverloadedFunction(Initializer,
- T1,
- false,
- Found);
- if (!Fn) {
+ if (FunctionDecl *Fn = S.ResolveAddressOfOverloadedFunction(Initializer,
+ T1,
+ false,
+ Found)) {
+ Sequence.AddAddressOverloadResolutionStep(Fn, Found);
+ cv2T2 = Fn->getType();
+ T2 = cv2T2.getUnqualifiedType();
+ } else if (!T1->isRecordType()) {
Sequence.SetFailed(InitializationSequence::FK_AddressOfOverloadFailed);
return;
}
-
- Sequence.AddAddressOverloadResolutionStep(Fn, Found);
- cv2T2 = Fn->getType();
- T2 = cv2T2.getUnqualifiedType();
}
// Compute some basic properties of the types and the initializer.
@@ -2604,7 +2603,9 @@
// We handled the function type stuff above.
if (!((isLValueRef && T1Quals.hasConst() && !T1Quals.hasVolatile()) ||
(isRValueRef && InitCategory.isRValue()))) {
- if (ConvOvlResult && !Sequence.getFailedCandidateSet().empty())
+ if (S.Context.getCanonicalType(T2) == S.Context.OverloadTy)
+ Sequence.SetFailed(InitializationSequence::FK_AddressOfOverloadFailed);
+ else if (ConvOvlResult && !Sequence.getFailedCandidateSet().empty())
Sequence.SetOverloadFailure(
InitializationSequence::FK_ReferenceInitOverloadFailed,
ConvOvlResult);
@@ -2706,6 +2707,8 @@
Sequence.SetOverloadFailure(
InitializationSequence::FK_ReferenceInitOverloadFailed,
ConvOvlResult);
+ else if (S.Context.getCanonicalType(T2) == S.Context.OverloadTy)
+ Sequence.SetFailed(InitializationSequence::FK_AddressOfOverloadFailed);
else
Sequence.SetFailed(InitializationSequence::FK_ReferenceInitFailed);
return;
Modified: cfe/branches/Apple/whitney/test/SemaCXX/addr-of-overloaded-function.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/test/SemaCXX/addr-of-overloaded-function.cpp?rev=118569&r1=118568&r2=118569&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/test/SemaCXX/addr-of-overloaded-function.cpp (original)
+++ cfe/branches/Apple/whitney/test/SemaCXX/addr-of-overloaded-function.cpp Tue Nov 9 11:32:22 2010
@@ -116,3 +116,32 @@
add_property(&wrap_mean); // expected-error{{no matching function for call to 'add_property'}}
}
}
+
+namespace PR7425 {
+ template<typename T>
+ void foo()
+ {
+ }
+
+ struct B
+ {
+ template<typename T>
+ B(const T&)
+ {
+ }
+ };
+
+ void bar(const B& b)
+ {
+ }
+
+ void bar2(const B& b = foo<int>)
+ {
+ }
+
+ void test(int argc, char** argv)
+ {
+ bar(foo<int>);
+ bar2();
+ }
+}
More information about the llvm-branch-commits
mailing list