Skip to content

Commit 93e947d

Browse files
author
Your Name
committed
Add some todo tests
1 parent 753563f commit 93e947d

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

test/testsimplifytemplate.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6827,6 +6827,38 @@ class TestSimplifyTemplate : public TestFixture {
68276827
"void use ( long l ) { g ( l ) ; }";
68286828
ASSERT_EQUALS(exp, tok(code));
68296829
}
6830+
{
6831+
// substitution of the template would fail (SFINAE) and the non template
6832+
// overload wins the overload resolution => don't deduce
6833+
const char code[] = "template<class T>\n"
6834+
"typename T::type f(T x) { return x; }\n"
6835+
"int f(int x) { return x; }\n"
6836+
"int use(int y) { return f(y); }";
6837+
const char exp[] = "template < class T > "
6838+
"T :: type f ( T x ) { return x ; } "
6839+
"int f ( int x ) { return x ; } "
6840+
"int use ( int y ) { return f ( y ) ; }";
6841+
ASSERT_EQUALS(exp, tok(code));
6842+
}
6843+
{
6844+
// same overload set with a literal argument: the literal deduction runs
6845+
// before any type information exists and has no overload guards, so it
6846+
// wrongly instantiates the template instead of keeping the call to the
6847+
// non template overload
6848+
const char code[] = "template<class T>\n"
6849+
"typename T::type f(T x) { return x; }\n"
6850+
"int f(int x) { return x; }\n"
6851+
"int use() { return f(1); }";
6852+
const char exp[] = "template < class T > "
6853+
"T :: type f ( T x ) { return x ; } "
6854+
"int f ( int x ) { return x ; } "
6855+
"int use ( ) { return f ( 1 ) ; }";
6856+
const char act[] = "int :: type f<int> ( int x ) ; "
6857+
"int f ( int x ) { return x ; } "
6858+
"int use ( ) { return f<int> ( 1 ) ; } "
6859+
"int :: type f<int> ( int x ) { return x ; }";
6860+
TODO_ASSERT_EQUALS(exp, act, tok(code));
6861+
}
68306862
}
68316863

68326864
void templateTypeDeduction15()

0 commit comments

Comments
 (0)