re PR c++/52521 ([C++11] user defined literals and order of declaration)
authorJakub Jelinek <jakub@redhat.com>
Wed, 14 Mar 2012 08:30:23 +0000 (09:30 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 14 Mar 2012 08:30:23 +0000 (09:30 +0100)
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.

From-SVN: r185375

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/udlit-args2.C [new file with mode: 0644]

index 6ef5545fbf5601ff6c939c0af48688d0834d143c..7f3acbd6c8bc197c2dacf184f023eddc90575f4a 100644 (file)
@@ -1,3 +1,10 @@
+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.
+
 2012-01-30  Dodji Seketeli  <dodji@redhat.com>
 
        PR c++/51641
index c6bd2906203b646f5d7fe65e5ce59451ecc1ec24..b3c87a8047ddb3c96ffc352f07564f5d8d598293 100644 (file)
@@ -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,gc) *args)
                                       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;
        }
     }
index 0f8f7a1d2f7a8b29071b3bc3b90231864ba21742..11c8e8fa40aadb87294f85e6b9d7523065b3f7de 100644 (file)
@@ -1,3 +1,8 @@
+2012-03-14  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/52521
+       * g++.dg/cpp0x/udlit-args2.C: New test.
+
 2012-03-13  Oleg Endo  <olegendo@gcc.gnu.org>
 
        PR target/48596
diff --git a/gcc/testsuite/g++.dg/cpp0x/udlit-args2.C b/gcc/testsuite/g++.dg/cpp0x/udlit-args2.C
new file mode 100644 (file)
index 0000000..1e7190f
--- /dev/null
@@ -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;