gcc/gcc47-pr52521.patch

53 lines
1.5 KiB
Diff

2012-03-14 Jakub Jelinek <jakub@redhat.com>
PR c++/52521
* parser.c (lookup_literal_operator): Return fn only if
processed all arguments from args vector and argtypes is
void_list_node.
* g++.dg/cpp0x/udlit-args2.C: New test.
--- gcc/cp/parser.c (revision 185374)
+++ gcc/cp/parser.c (revision 185375)
@@ -1,6 +1,6 @@
/* C++ Parser.
Copyright (C) 2000, 2001, 2002, 2003, 2004,
- 2005, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+ 2005, 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
Written by Mark Mitchell <mark@codesourcery.com>.
This file is part of GCC.
@@ -3581,7 +3581,13 @@ lookup_literal_operator (tree name, VEC(
TREE_TYPE (tparm))))
found = false;
}
- if (found)
+ if (found
+ && ix == VEC_length (tree, args)
+ /* May be this should be sufficient_parms_p instead,
+ depending on how exactly should user-defined literals
+ work in presence of default arguments on the literal
+ operator parameters. */
+ && argtypes == void_list_node)
return fn;
}
}
--- gcc/testsuite/g++.dg/cpp0x/udlit-args2.C (revision 0)
+++ gcc/testsuite/g++.dg/cpp0x/udlit-args2.C (revision 185375)
@@ -0,0 +1,15 @@
+// PR c++/52521
+// { dg-do compile }
+// { dg-options -std=c++11 }
+
+#include <cstddef>
+
+int operator "" _a (const char *);
+int operator "" _a (const char *, std::size_t);
+int a = 123_a;
+int a2 = "abc"_a;
+
+int operator "" _b (const char *, std::size_t);
+int operator "" _b (const char *);
+int b = 123_b;
+int b2 = "abc"_b;