diff mbox

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

Message ID 4EDE16DB.1070804@verizon.net
State New
Headers show

Commit Message

Ed Smith-Rowland Dec. 6, 2011, 1:21 p.m. UTC
This time with patch.

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 current overload
     is function_type.

Comments

Jason Merrill Dec. 6, 2011, 7:27 p.m. UTC | #1
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
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 182038)
+++ gcc/cp/parser.c	(working copy)
@@ -3563,6 +3563,8 @@ 
       bool found = true;
       tree fn = OVL_CURRENT (fns);
       tree argtypes = NULL_TREE;
+      if (TREE_CODE (TREE_TYPE (fn)) != FUNCTION_TYPE)
+	return error_mark_node;
       argtypes = TYPE_ARG_TYPES (TREE_TYPE (fn));
       if (argtypes != NULL_TREE)
 	{