This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] PR64959: SFINAE in UDLs


Hi all,

atm enable_if cannot be used to select between overload of UDLs. E.g.
https://gcc.gnu.org/bugzilla/attachment.cgi?id=34684 will not compile.
This can be easily fixed making sure that lookup_literal_operator
returns all the possible candidates and not just the first match. I
made some more changes in parser.c to improve diagnostic in case of
failures. Four testcases added:
    * udlit-sfinae.C
    * udlit-sfinae.neg.C
    * udlit-char-template-sfinae.C
    * udlit-char-template-sfinae-neg.C

The first make check showed a failures in udlit-resolve.C. Actually
the failures was a false positive, because UDLs lookup is a normal
unqualified name lookup. I added two tests:
  * udlit-namespace-ambiguous.C
  * udlit-namespace-ambiguous-neg.C

At the end I also noticed a bug in string template literals. As per
N3599 the lookup should give precedence to operator""_t(const char*,
unsigned long). I updated the code in parser.C and added a test.

Please note that this is my first gcc patch :)

2015-2-9 Andrea Azzarone <azzaronea@gmail.com>
    PR c++/64959

    * gcc/cp/parser.c: Make sure lookup_literal_operator returns all
the possible candidates. Also improve the diagnostic messages.
    * gcc/testsuite/g++.dg/cpp0x/udlit-namespace-ambiguous.C: Add test
case to make sure gcc detects ambiguous UDL declarations.
    * gcc/testsuite/g++.dg/cpp0x/udlit-namespace-using-directive.C:
Add test case to make sure gcc correctly handles using directive for
UDLs.
    * gcc/testsuite/g++.dg/cpp0x/udlit-resolve.C: Remove a incorrect test case.
    * gcc/testsuite/g++.dg/cpp0x/udlit-sfinae.C: Add a test case to
make sure that enable_if can be used to select between overloads of
UDLs.
    * gcc/testsuite/g++.dg/cpp0x/udlit-sfinae-neg.C: Add a test case
to make sure gcc correctly detects substitution failures when all the
UDSL overloads are disabled by enable_if.
    * gcc/testsuite/g++.dg/cpp1y/udlit-char-template-sfinae-neg.C:
Like cpp0x/udlit-sfinae-neg.C but for string template literals.
    * gcc/testsuite/g++.dg/cpp1y/udlit-char-template-sfinae.C: Like
cpp0x/udlit-sfinae.C but for string template literals.
    * gcc/testsuite/g++.dg/cpp1y/udlit-char-template-vs-std-literal-operator.C:
Add a test to make sure that string template literals have a smaller
priority than standard literal operators.


-- 
Andrea Azzarone

Attachment: udl-sfinae.diff
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]