[cfe-commits] [PATCH] for Bug7505 and three other related issues

Faisal Vali faisalv at yahoo.com
Fri Sep 10 15:26:40 PDT 2010

The patch fixes the following related bugs:

1) Fix bug http://llvm.org/bugs/show_bug.cgi?id=7505
  (overload resolution of &foo<int> when it identifies a single function)

template<class T> void foo(T);
bool b = &foo<int>; // now, ok.

-- added a call to Sema::ResolveSingleFunctionTemplateSpecialization in
  Sema::ResolveAddressOfOverloadedFunction prior to any other deduction
  or resolution to check to see if the name identifies a single function

-- modified Sema.h to add a 'Complain' flag to getMostSpecialized and
  ResolveSingleFunctionTemplateSpecialization so that we can percolate
  it through to these other functions that do Complain even if we
  don't intend to from ResolveAddressOfOverloadedFunction
  (required adding another call to ResolveOverload in SemaExpr.cpp with
   Complain set to true, since PerformImplicitConversion was calling
   it with 'false' yet the function was still complaining)
   (Sema.h, SemaTemplateDeduction.cpp)

-- made some cosmetic changes (left the major refactoring for the next revision)
  to ResolveSingleFunctionTemplateSpecialization

2) Fix invalid conversion of an unresolved overloaded name into bool via '!'
template<class T> void foo(T);
bool b = !&foo;  // this should be ambiguous
 -- Added a call to PerformContextuallyConvertToBool in CreateBuiltinUnaryOp
    to ensure that the OverloadTy does not leak through (semaExpr.cpp)

3) Fix for a better error message when we can't resolve a function name
 - When TryImplicitConversion fails in InitializationSequence Constructor
   before calling it a conversion failure, check to see if it could resolve
   the name, and if it can't then it is an overloadresolution failure

4) Fix a bug that allowed invalid deduction during a c-style cast to a
function reference
 - template<class T> void f(T);
 - (void)((void (&)(int,char))f); // this would compile and should error!!
 - (void)((void (*)(int,char))f);  // error as expected
 - In 'TryStaticImplicitCast' before allowing a cstyle cast if a
simple static cast failed,
   make sure we are not trying to cstyle cast a 'name' that could not
be resolved
   using the information in the cast (i.e the destination signature)

I verified the tests in /CXX and in /SemaCXX.

As always, any feedback will be kindly appreciated :)
Faisal Vali
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch-for-submission.patch
Type: application/octet-stream
Size: 31860 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20100910/b7ac5135/attachment.obj>

More information about the cfe-commits mailing list