If a default argument is a dependent type, get the real type from the desugared

template.  Passing around dependent types can lead to integral arguments that
cannot be evaluated.

llvm-svn: 186757
This commit is contained in:
Richard Trieu 2013-07-20 03:49:02 +00:00
parent 08905dd60b
commit 8ed6f2aacf
2 changed files with 31 additions and 5 deletions

View File

@ -1054,10 +1054,14 @@ class TemplateDiff {
if (!Iter.isEnd())
return Iter->getAsType();
if (!isVariadic)
return DefaultTTPD->getDefaultArgument();
if (isVariadic)
return QualType();
return QualType();
QualType ArgType = DefaultTTPD->getDefaultArgument();
if (ArgType->isDependentType())
return Iter.getDesugar().getAsType();
return ArgType;
}
/// GetExpr - Retrieves the template expression argument, including default

View File

@ -935,10 +935,10 @@ namespace DependentDefault {
B<int, char> b3;
b1 = b2;
// CHECK-ELIDE-NOTREE: no viable overloaded '='
// CHECK-ELIDE-NOTREE: no known conversion from 'B<char, (default) Trait<T>::Ty>' to 'B<int, int>'
// CHECK-ELIDE-NOTREE: no known conversion from 'B<char, [...]>' to 'B<int, [...]>'
b3 = b1;
// CHECK-ELIDE-NOTREE: no viable overloaded '='
// CHECK-ELIDE-NOTREE: no known conversion from 'B<[...], (default) Trait<T>::Ty>' to 'B<[...], char>'
// CHECK-ELIDE-NOTREE: no known conversion from 'B<[...], (default) int>' to 'B<[...], char>'
b2 = b3;
// CHECK-ELIDE-NOTREE: no viable overloaded '='
// CHECK-ELIDE-NOTREE: no known conversion from 'B<int, char>' to 'B<char, int>'
@ -1029,6 +1029,28 @@ namespace PointerArguments {
}
}
namespace DependentInt {
template<int Num> struct INT;
template <class CLASS, class Int_wrapper = INT<CLASS::val> >
struct C;
struct N {
static const int val = 1;
};
template <class M_T>
struct M {};
void test() {
using T1 = M<C<int, INT<0>>>;
using T2 = M<C<N>>;
T2 p;
T1 x = p;
// CHECK-ELIDE-NOTREE: no viable conversion from 'M<C<struct DependentInt::N, INT<1>>>' to 'M<C<int, INT<0>>>'
}
}
// CHECK-ELIDE-NOTREE: {{[0-9]*}} errors generated.
// CHECK-NOELIDE-NOTREE: {{[0-9]*}} errors generated.
// CHECK-ELIDE-TREE: {{[0-9]*}} errors generated.