diff mbox

[C++] ICE with invalid user-defined literals (PR c++/51420)

Message ID 4EDEC3A0.90104@verizon.net
State New
Headers show

Commit Message

Ed Smith-Rowland Dec. 7, 2011, 1:38 a.m. UTC
On 12/06/2011 02:27 PM, Jason Merrill wrote:
> On 12/06/2011 08:21 AM, Ed Smith-Rowland wrote:
>> * parser.c (lookup_literal_operator): Check that current overload
>> is function_type.
>
> Instead of checking here, let's check is_overloaded_fn (decl) right 
> after the lookup name.
>
> Jason
>
OK,

This passes all tests including the new test case.

gcc/testsuite:

2011-12-06  Ed Smith-Rowland <3dw4rd@verizon.net>

     PR c++/51420
     * g++.dg/cpp0x/pr51420.C: New.


gcc/cp:

2011-12-06  Ed Smith-Rowland <3dw4rd@verizon.net>

     PR c++/51420
     * parser.c (lookup_literal_operator): Check that declaration is an
     overloaded function.

Comments

Jason Merrill Dec. 7, 2011, 5:17 p.m. UTC | #1
Applied, thanks.

Jason
diff mbox

Patch

Index: gcc/testsuite/g++.dg/cpp0x/pr51420.C
===================================================================
--- gcc/testsuite/g++.dg/cpp0x/pr51420.C	(revision 0)
+++ gcc/testsuite/g++.dg/cpp0x/pr51420.C	(revision 0)
@@ -0,0 +1,8 @@ 
+// { dg-options "-std=c++11" }
+
+void
+foo()
+{
+  float x = operator"" _F();  //  { dg-error  "was not declared in this scope" }
+  float y = 0_F;  //  { dg-error  "unable to find numeric literal operator" }
+}
Index: gcc/cp/parser.c
===================================================================
--- gcc/cp/parser.c	(revision 182068)
+++ gcc/cp/parser.c	(working copy)
@@ -3554,7 +3554,7 @@ 
 {
   tree decl, fns;
   decl = lookup_name (name);
-  if (!decl || decl == error_mark_node)
+  if (!decl || !is_overloaded_fn (decl))
     return error_mark_node;
 
   for (fns = decl; fns; fns = OVL_NEXT (fns))