From a65cf0b4b9291e6d5301b47c2cfd02790dd96c9b Mon Sep 17 00:00:00 2001 From: jakub Date: Thu, 22 Mar 2012 10:10:24 +0000 Subject: [PATCH] Backported from mainline 2012-03-14 Jakub Jelinek 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_7-branch@185683 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 10 ++++++++++ gcc/cp/parser.c | 10 ++++++++-- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/cpp0x/udlit-args2.C | 15 +++++++++++++++ 4 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/udlit-args2.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index ea57a4766ae..806ac9b50c7 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,13 @@ +2012-03-22 Jakub Jelinek + + Backported from mainline + 2012-03-14 Jakub Jelinek + + 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-03-22 Release Manager * GCC 4.7.0 released. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 491f48e0fcc..c4b4dd44855 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -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 . 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; } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 96226fa35d9..5ee035f3a6b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,6 +1,11 @@ 2012-03-22 Jakub Jelinek Backported from mainline + 2012-03-14 Jakub Jelinek + + PR c++/52521 + * g++.dg/cpp0x/udlit-args2.C: New test. + 2012-03-13 Jakub Jelinek PR c/52577 diff --git a/gcc/testsuite/g++.dg/cpp0x/udlit-args2.C b/gcc/testsuite/g++.dg/cpp0x/udlit-args2.C new file mode 100644 index 00000000000..1e7190fc8f7 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/udlit-args2.C @@ -0,0 +1,15 @@ +// PR c++/52521 +// { dg-do compile } +// { dg-options -std=c++11 } + +#include + +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; -- 2.11.0