diff mbox

Generic lambda and implicit function template commits reverted

Message ID 1d1d419f76ca0b56520726b3e3cf5ac1@imap.force9.net
State New
Headers show

Commit Message

Adam Butcher Sept. 15, 2013, 1:22 p.m. UTC
Hi Jason,

Could you cast your eyes over these changes please?  I intend to roll
them up into the appropriate patches.  I will make sure I bootstrap
and "before-and-after" the g++.dg testsuite before pushing next time!


[PATCH 1/5] Fix uninitialized variables causing breakage with -Werror.

   Not actually sure that this should be necessary.  Initialization of
   'direct_argvec' and 'call' and subsequent references are behind
   '!generic_lambda_p' and 'generic_lambda_p' tests respectively.
   'generic_lambda_p' is declared 'const bool'.
   To pacify -Wmaybe-uninitialized, I have initialized them to 0.


[PATCH 2/5] Don't accept 'auto' as the 'type' of a template parameter.

   The implicit function template code was incorrectly firing in a 
template
   parameter list.


[PATCH 3/5] Fix location diagnostics by returning to the deprecated
	    'input_location' global; must be a better fix for this.

   Don't know why 'location_of (type)' gave "<built-in>:" rather than
   "file:line:col:".  My current workaround is to return to using
   'input_location'.  This gives the correct result but I doubt it is
   acceptable.


[PATCH 4/5] Lift CALL_FROM_THUNK_P setting to above the potential
	    'build_cplus_new' call to prevent ICE due to unexpected tree type.

   Plain old bug which I introduced when reorganizing the conversion op 
code.


[PATCH 5/5] Handle forward declaration of implicit function templates.
	    Previously kept template parameter types in scope.

   Another bug.  Template parameter list erroneously left in scope.


Cheers,
Adam


[PATCH 1/5] Fix uninitialized variables causing breakage with -Werror.
---
--

Comments

Jason Merrill Sept. 15, 2013, 2:45 p.m. UTC | #1
On 09/15/2013 06:22 AM, Adam Butcher wrote:
> [PATCH 1/5] Fix uninitialized variables causing breakage with -Werror.
> [PATCH 2/5] Don't accept 'auto' as the 'type' of a template parameter.

OK.

> [PATCH 3/5] Fix location diagnostics by returning to the deprecated
>          'input_location' global; must be a better fix for this.
>
>    Don't know why 'location_of (type)' gave "<built-in>:" rather than
>    "file:line:col:".  My current workaround is to return to using
>    'input_location'.  This gives the correct result but I doubt it is
>    acceptable.

This seems to be because make_auto_1 sets the location of the auto type 
to BUILTINS_LOCATION; I don't remember why I did that.  Changing it to 
use input_location seems appropriate.

> [PATCH 4/5] Lift CALL_FROM_THUNK_P setting to above the potential
>          'build_cplus_new' call to prevent ICE due to unexpected tree type.
> [PATCH 5/5] Handle forward declaration of implicit function templates.
>          Previously kept template parameter types in scope.

OK.

Jason
diff mbox

Patch

diff --git a/gcc/cp/lambda.c b/gcc/cp/lambda.c
index 2d20333..0da22fd 100644
--- a/gcc/cp/lambda.c
+++ b/gcc/cp/lambda.c
@@ -792,8 +792,8 @@  maybe_add_lambda_conv_op (tree type)
       particular, parameter pack expansions are marked 
PACK_EXPANSION_LOCAL_P in
       the body CALL, but not in DECLTYPE_CALL.  */

-  vec<tree, va_gc> *direct_argvec;
-  tree decltype_call = 0, call;
+  vec<tree, va_gc> *direct_argvec = 0;
+  tree decltype_call = 0, call = 0;
    tree fn_result = TREE_TYPE (TREE_TYPE (callop));

    if (generic_lambda_p)
-- 


[PATCH 2/5] Don't accept 'auto' as the 'type' of a template parameter.
---
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index e6e24f8..6a4e863 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -10323,7 +10323,12 @@  grokdeclarator (const cp_declarator 
*declarator,

        if (type_uses_auto (type))
  	{
-	  if (current_class_type && LAMBDA_TYPE_P (current_class_type))
+	  if (template_parm_flag)
+	    {
+	      error ("template parameter declared %<auto%>");
+	      type = error_mark_node;
+	    }
+	  else if (current_class_type && LAMBDA_TYPE_P (current_class_type))
  	    {
  	      if (cxx_dialect < cxx1y)
  		pedwarn (location_of (type), 0,
-- 


[PATCH 3/5] Fix location diagnostics by returning to the deprecated 
'input_location' global; must be a better fix for this.

Using 'location_of (type)' yields "<built-in>: " rather than 
"file:line:col: "
---
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 6a4e863..a948580 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -10331,18 +10331,18 @@  grokdeclarator (const cp_declarator 
*declarator,
  	  else if (current_class_type && LAMBDA_TYPE_P (current_class_type))
  	    {
  	      if (cxx_dialect < cxx1y)
-		pedwarn (location_of (type), 0,
+		pedwarn (input_location, 0,
  			 "use of %<auto%> in lambda parameter declaration "
  			 "only available with "
  			 "-std=c++1y or -std=gnu++1y");
  	    }
  	  else if (cxx_dialect < cxx1y)
-	    pedwarn (location_of (type), 0,
+	    pedwarn (input_location, 0,
  		     "use of %<auto%> in parameter declaration "
  		     "only available with "
  		     "-std=c++1y or -std=gnu++1y");
  	  else
-	    pedwarn (location_of (type), OPT_Wpedantic,
+	    pedwarn (input_location, OPT_Wpedantic,
  		     "ISO C++ forbids use of %<auto%> in parameter "
  		     "declaration");
  	}
-- 


[PATCH 4/5] Lift CALL_FROM_THUNK_P setting to above the potential 
'build_cplus_new' call to prevent ICE due to unexpected tree type.
---
diff --git a/gcc/cp/lambda.c b/gcc/cp/lambda.c
index 0da22fd..0154840 100644
--- a/gcc/cp/lambda.c
+++ b/gcc/cp/lambda.c
@@ -883,16 +883,17 @@  maybe_add_lambda_conv_op (tree type)
  	     tf_warning_or_error);
  	  --processing_template_decl;
  	}
+      CALL_FROM_THUNK_P (call) = 1;
      }
    else
      {
        call = build_call_a (callop,
  			   direct_argvec->length (),
  			   direct_argvec->address ());
+      CALL_FROM_THUNK_P (call) = 1;
        if (MAYBE_CLASS_TYPE_P (TREE_TYPE (call)))
  	call = build_cplus_new (TREE_TYPE (call), call, tf_warning_or_error);
      }
-  CALL_FROM_THUNK_P (call) = 1;

    tree stattype = build_function_type (fn_result, FUNCTION_ARG_CHAIN 
(callop));

-- 


[PATCH 5/5] Handle forward declaration of implicit function templates.  
Previously kept template parameter types in scope.
---
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 5dbae75..9c26660 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -16295,10 +16295,12 @@  cp_parser_init_declarator (cp_parser* parser,

    /* Peek at the next token.  */
    token = cp_lexer_peek_token (parser->lexer);
+
+  if (function_declarator_p (declarator))
+    {
        /* Check to see if the token indicates the start of a
  	 function-definition.  */
-  if (function_declarator_p (declarator)
-      && cp_parser_token_starts_function_definition_p (token))
+      if (cp_parser_token_starts_function_definition_p (token))
  	{
  	  if (!function_definition_allowed_p)
  	    {
@@ -16346,6 +16348,9 @@  cp_parser_init_declarator (cp_parser* parser,
  	      return decl;
  	    }
  	}
+      else if (parser->fully_implicit_function_template_p)
+	decl = finish_fully_implicit_template (parser, decl);
+    }

    /* [dcl.dcl]