Add regression test for #6299. Fix clang compiler warning due to doxygen comment

This commit is contained in:
Alexander Mai 2015-08-14 18:27:03 +02:00
parent a297a03b64
commit 8b433fa053
2 changed files with 39 additions and 1 deletions

View File

@ -496,7 +496,7 @@ public:
* ... * ...
* const char *str[] = {"string", "wstring"}; * const char *str[] = {"string", "wstring"};
* sVar->isStlType(str) == true * sVar->isStlType(str) == true
* @param stlTypes set of stl types * @param stlType stl type
* @return true if it is an stl type and its type matches any of the types in 'stlTypes' * @return true if it is an stl type and its type matches any of the types in 'stlTypes'
*/ */
bool isStlType(const std::string& stlType) const { bool isStlType(const std::string& stlType) const {

View File

@ -86,6 +86,7 @@ private:
TEST_CASE(template53); // #4335 - bail out for valid code TEST_CASE(template53); // #4335 - bail out for valid code
TEST_CASE(template54); // #6587 - memory corruption upon valid code TEST_CASE(template54); // #6587 - memory corruption upon valid code
TEST_CASE(template55); // #6604 - simplify "const const" to "const" in template instantiations TEST_CASE(template55); // #6604 - simplify "const const" to "const" in template instantiations
TEST_CASE(template_enum); // #6299 Syntax error in complex enum declaration (including template)
TEST_CASE(template_unhandled); TEST_CASE(template_unhandled);
TEST_CASE(template_default_parameter); TEST_CASE(template_default_parameter);
TEST_CASE(template_default_type); TEST_CASE(template_default_type);
@ -996,6 +997,43 @@ private:
"A<int> a(0);")); "A<int> a(0);"));
} }
void template_enum() {
const char code1[] = "template <class T>\n"
"struct Unconst {\n"
" typedef T type;\n"
"};\n"
"template <class T>\n"
"struct Unconst<const T> {\n"
" typedef T type;\n"
"};\n"
"template <class T>\n"
"struct Unconst<const T&> {\n"
" typedef T& type;\n"
"};\n"
"template <class T>\n"
"struct Unconst<T* const> {\n"
" typedef T* type;\n"
"};\n"
"template <class T1, class T2>\n"
"struct type_equal {\n"
" enum { value = 0 };\n"
"};\n"
"template <class T>\n"
"struct type_equal<T, T> {\n"
" enum { value = 1 };\n"
"};\n"
"template<class T>\n"
"struct template_is_const\n"
"{\n"
" enum {value = !type_equal<T, typename Unconst<T>::type>::value };\n"
"};";
const char expected1[]="template < class T > struct Unconst { } ; template < class T > struct type_equal<T,T> { } ;"
"template < class T > struct template_is_const { } ; struct type_equal<T,T> { } ; struct Unconst<constT*const> { } ;"
"struct Unconst<constT&*const> { } ; struct Unconst<T*const*const> { } ; struct Unconst<T*const> { } ; struct Unconst<T*const> { } ;"
"struct Unconst<T*const> { } ; struct Unconst<constT&><};template<T> { } ; struct Unconst<constT><};template<T> { } ;";
ASSERT_EQUALS(expected1, tok(code1));
}
void template_default_parameter() { void template_default_parameter() {
{ {
const char code[] = "template <class T, int n=3>\n" const char code[] = "template <class T, int n=3>\n"