This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [RFA] PR c++/40808
On Fri, Oct 23, 2009 at 08:47:28AM -0700, Jason Merrill wrote:
> On 10/23/2009 06:34 AM, Dodji Seketeli wrote:
>> +// { dg-final {scan-assembler "_ZNK5DummyclI3GenEENT_3SigIE10ResultTypeERKS2_" } }
>
> Does this test actually run without a space between { and scan-assembler?
Yes it does. But I have changed the line nevertheless.
Incidentally, Jakub noticed that my tree was a bit outdated as there now is
a mangle33.C file in the tree already. I have renamed the test file
to mangle34.C instead.
commit 00c533bedac6f1ca950d13b1287e726da9d0d1ec
Author: Dodji Seketeli <dodji@redhat.com>
Date: Fri Oct 23 14:02:19 2009 +0200
Fix for PR c++/40808
gcc/cp/ChangeLog:
PR c++/40808
* mangle.c (write_template_args): Allow mangling of empty template
argument list. Updated function comments.
gcc/testsuite/ChangeLog:
PR c++/40808
* g++.dg/abi/mangle34.C: New test
diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c
index f9a5503..d4bcbac 100644
--- a/gcc/cp/mangle.c
+++ b/gcc/cp/mangle.c
@@ -2284,21 +2284,22 @@ write_class_enum_type (const tree type)
/* Non-terminal <template-args>. ARGS is a TREE_VEC of template
arguments.
- <template-args> ::= I <template-arg>+ E */
+ <template-args> ::= I <template-arg>* E */
static void
write_template_args (tree args)
{
int i;
- int length = TREE_VEC_LENGTH (args);
+ int length = 0;
MANGLE_TRACE_TREE ("template-args", args);
write_char ('I');
- gcc_assert (length > 0);
+ if (args)
+ length = TREE_VEC_LENGTH (args);
- if (TREE_CODE (TREE_VEC_ELT (args, 0)) == TREE_VEC)
+ if (args && TREE_CODE (TREE_VEC_ELT (args, 0)) == TREE_VEC)
{
/* We have nested template args. We want the innermost template
argument list. */
diff --git a/gcc/testsuite/g++.dg/abi/mangle34.C b/gcc/testsuite/g++.dg/abi/mangle34.C
new file mode 100644
index 0000000..08c3bc0
--- /dev/null
+++ b/gcc/testsuite/g++.dg/abi/mangle34.C
@@ -0,0 +1,41 @@
+// Contributed by Dodji Seketeli <dodji@redhat.com>
+// Origin PR c++/40808
+// { dg-do compile }
+// This tests the mangling of empty template argument list in a template
+// id.
+// { dg-final { scan-assembler "_ZNK5DummyclI3GenEENT_3SigIE10ResultTypeERKS2_" } }
+
+
+struct Void {};
+
+template <class R> struct FunType {
+ typedef R ResultType;
+};
+
+struct WrongNumberOfSigArgs {};
+
+template <typename R> struct CFunType {
+ template <class Dummy1=Void, class Dummy2=Void> struct Sig : public
+FunType<WrongNumberOfSigArgs> {};
+ template <class Dummy> struct Sig<Void,Dummy> : public FunType<R> {};
+};
+
+struct Dummy {
+ template <typename F> typename F::template Sig<>::ResultType operator()(F
+const& f) const {
+ return typename F::template Sig<>::ResultType(0);
+ }
+};
+
+struct Gen: public CFunType<int> {
+ int operator()() const {return 0;}
+ Gen() {}
+};
+
+int myfunction() {
+ return Dummy()(Gen());
+}
+
+int main() {
+ myfunction();
+}
--
Dodji Seketeli
Red Hat