summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Ridge2013-02-17 20:28:11 (EST)
committerSergey Prigogin2013-02-19 23:14:57 (EST)
commit81885d232fec146ec4c1d6c1fbac552daff416ea (patch)
tree8e1bd2264f4aee9a18a5a066a939cb7e6b5f24c9
parentc48e321ea3874237194f2ee4c213a2769ad04306 (diff)
downloadorg.eclipse.cdt-81885d232fec146ec4c1d6c1fbac552daff416ea.zip
org.eclipse.cdt-81885d232fec146ec4c1d6c1fbac552daff416ea.tar.gz
org.eclipse.cdt-81885d232fec146ec4c1d6c1fbac552daff416ea.tar.bz2
Bug 401024 - Error involving variadic templatesrefs/changes/26/10426/2
Change-Id: Ic5e0b3176e87e6dcecfb528367ce5f8eea4760c1 Reviewed-on: https://git.eclipse.org/r/10426 Reviewed-by: Sergey Prigogin <eclipse.sprigogin@gmail.com> IP-Clean: Sergey Prigogin <eclipse.sprigogin@gmail.com> Tested-by: Sergey Prigogin <eclipse.sprigogin@gmail.com>
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java49
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTTypeUtil.java2
2 files changed, 46 insertions, 5 deletions
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java
index 31e4ef5..30a2844 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java
@@ -4509,25 +4509,25 @@ public class AST2TemplateTests extends AST2TestBase {
parseAndCheckBindings(code);
BindingAssertionHelper bh= new BindingAssertionHelper(code, CPP);
ICPPFunctionTemplate f= bh.assertNonProblem("f1", 2);
- assertEquals("void (int (*)(#0 ...))", ASTTypeUtil.getType(f.getType(), true));
+ assertEquals("void (int (*)(#0(...) ...))", ASTTypeUtil.getType(f.getType(), true));
assertFalse(f.getParameters()[0].isParameterPack());
f= bh.assertNonProblem("f2", 2);
- assertEquals("void (int (* ...)(#0, int))", ASTTypeUtil.getType(f.getType(), true));
+ assertEquals("void (int (* ...)(#0(...), int))", ASTTypeUtil.getType(f.getType(), true));
assertTrue(f.getParameters()[0].isParameterPack());
f= bh.assertNonProblem("f3", 2);
- assertEquals("void (#0 (* ...)())", ASTTypeUtil.getType(f.getType(), true));
+ assertEquals("void (#0(...) (* ...)())", ASTTypeUtil.getType(f.getType(), true));
assertTrue(f.getParameters()[0].isParameterPack());
f= bh.assertNonProblem("f4", 2);
assertEquals("void (int (& ...)[3 *0 0])", ASTTypeUtil.getType(f.getType(), true));
assertTrue(f.getParameters()[0].isParameterPack());
f= bh.assertNonProblem("f5", 2);
- assertEquals("void (#0 ...)", ASTTypeUtil.getType(f.getType(), true));
+ assertEquals("void (#0(...) ...)", ASTTypeUtil.getType(f.getType(), true));
assertTrue(f.getParameters()[0].isParameterPack());
f= bh.assertNonProblem("f6", 2);
assertEquals("void (#0, ...)", ASTTypeUtil.getType(f.getType(), true));
assertFalse(f.getParameters()[0].isParameterPack());
f= bh.assertNonProblem("f7", 2);
- assertEquals("#0 ...", ASTTypeUtil.getType(f.getExceptionSpecification()[0], true));
+ assertEquals("#0(...) ...", ASTTypeUtil.getType(f.getExceptionSpecification()[0], true));
}
// template<typename... Pack> class C1 {};
@@ -7165,4 +7165,43 @@ public class AST2TemplateTests extends AST2TestBase {
public void testDependentExpressionInvolvingFieldInNestedClass_399362() throws Exception {
parseAndCheckBindings();
}
+
+ // template <typename _Tp>
+ // struct remove_reference {
+ // typedef _Tp type;
+ // };
+ // template <typename>
+ // struct A {};
+ // template <typename From, typename To>
+ // struct waldo {
+ // typedef typename remove_reference<From>::type src_t;
+ // typedef A<src_t> type;
+ // };
+ // template <bool First>
+ // struct ice_or {
+ // static const bool value = First;
+ // };
+ // template <typename T>
+ // struct is_waldo {
+ // static const bool value = false;
+ // };
+ // template <typename... Args>
+ // struct contains_waldo {
+ // static const bool value = ice_or<is_waldo<typename remove_reference<Args>::type>::value...>::value;
+ // };
+ // template <bool>
+ // struct S {};
+ // struct Cat {
+ // void meow();
+ // };
+ // template <>
+ // struct S<false> {
+ // typedef Cat type;
+ // };
+ // int main() {
+ // S<contains_waldo<int>::value>::type t;
+ // }
+ public void testVariadicTemplates_401024() throws Exception {
+ parseAndCheckBindings();
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTTypeUtil.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTTypeUtil.java
index 5a25428..fd1a93f 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTTypeUtil.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTTypeUtil.java
@@ -424,6 +424,8 @@ public class ASTTypeUtil {
if (normalize) {
result.append('#');
result.append(Integer.toString(type.getParameterID(), 16));
+ if (type.isParameterPack())
+ result.append("(...)"); //$NON-NLS-1$
} else {
result.append(type.getName());
}