diff mbox

[C++] PR 58535

Message ID 524C46A9.5050809@oracle.com
State New
Headers show

Commit Message

Paolo Carlini Oct. 2, 2013, 4:15 p.m. UTC
Hi,

in this [4.8/4.9] diagnostic regression the gcc_assert in 
check_member_templates trips:

       /* The parser rejects any use of virtual in a function template.  */
       gcc_assert (!(TREE_CODE (decl) == FUNCTION_DECL
             && DECL_VIRTUAL_P (decl)));

the ultimate reason being that in r187587 we inadvertently (I suppose, 
because the change has no relation to the rest of the commit and isn't 
explained) changed cp_parser_function_specifier_opt to always set 
ds_virtual in decl_specs, upon error too. Thus the below first hunk 
simply reverts that change and is enough to fix the primary bug.

Then, in mainline only, we have a variant of the issue for our implicit 
function templates extension, which requires a little more work, because 
when we parse 'virtual' we don't know yet that all the function 
parameters will be auto. To handle that I'm adding a check in 
finish_fully_implicit_template.

Tested x86_64-linux.

Thanks,
Paolo.

/////////////////////////////
/cp
2013-10-02  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/58565
	* semantics.c (potential_constant_expression_1): Handle LABEL_EXPR.

/testsuite
2013-10-02  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/58565
	* g++.dg/parse/crash64.C: New.
diff mbox

Patch

Index: cp/semantics.c
===================================================================
--- cp/semantics.c	(revision 203101)
+++ cp/semantics.c	(working copy)
@@ -8422,6 +8422,7 @@  potential_constant_expression_1 (tree t, bool want
     case OVERLOAD:
     case TEMPLATE_ID_EXPR:
     case LABEL_DECL:
+    case LABEL_EXPR:
     case CONST_DECL:
     case SIZEOF_EXPR:
     case ALIGNOF_EXPR:
Index: testsuite/g++.dg/parse/crash64.C
===================================================================
--- testsuite/g++.dg/parse/crash64.C	(revision 0)
+++ testsuite/g++.dg/parse/crash64.C	(working copy)
@@ -0,0 +1,7 @@ 
+// PR c++/58565
+// { dg-options "" }
+
+void foo()
+{
+  int i = ({ L: ; });  // { dg-error "void value not ignored" }
+}