On 15.09.2013 15:45, Jason Merrill wrote:
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.
I've also added a case for rejecting 'auto' in a catch parameter.
[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.
Thanks. Doing that makes this patch unnecessary.
[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.
Rather than this, I've moved the call to 'build_cplus_new' back down to
after 'start_preparsed_function' as I needed to call
'set_flags_from_callee' prior to it but within function scope to prevent
regression of 49260 and 47263.
Deltas below. No regressions in g++.dg with these updates.
Cheers,
Adam
Subject: [PATCH] * pt.c (make_auto_1): Use input_location rather than
BUILTINS_LOCATION.
---
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 58f920e..70f13bb 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -20925,7 +20925,7 @@ static tree
make_auto_1 (tree name)
{
tree au = cxx_make_type (TEMPLATE_TYPE_PARM);
- TYPE_NAME (au) = build_decl (BUILTINS_LOCATION,
+ TYPE_NAME (au) = build_decl (input_location,
TYPE_DECL, name, au);
TYPE_STUB_DECL (au) = TYPE_NAME (au);
TEMPLATE_TYPE_PARM_INDEX (au) = build_template_parm_index
--
[PATCH] Move 'build_cplus_new' call to after 'start_preparsed_function'
and call 'set_flags_from_callee' prior to prevent ICE due to unexpected
tree type and fix exception handling.
---
diff --git a/gcc/cp/lambda.c b/gcc/cp/lambda.c
index 0da22fd..c9118d8 100644
--- a/gcc/cp/lambda.c
+++ b/gcc/cp/lambda.c
@@ -885,13 +885,10 @@ maybe_add_lambda_conv_op (tree type)
}
}
else
- {
call = build_call_a (callop,
direct_argvec->length (),
direct_argvec->address ());
- 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));
@@ -987,6 +984,12 @@ maybe_add_lambda_conv_op (tree type)
}
tree body = begin_function_body ();
tree compound_stmt = begin_compound_stmt (0);
+ if (!generic_lambda_p)
+ {
+ set_flags_from_callee (call);
+ if (MAYBE_CLASS_TYPE_P (TREE_TYPE (call)))
+ call = build_cplus_new (TREE_TYPE (call), call, tf_warning_or_error);
+ }
call = convert_from_reference (call);
finish_return_stmt (call);
--
[PATCH] Don't allow 'auto' in type of catch parameter.
---
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 6a4e863..80ceca1 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -10328,6 +10328,11 @@ grokdeclarator (const cp_declarator
*declarator,
error ("template parameter declared %<auto%>");
type = error_mark_node;
}
+ else if (decl_context == CATCHPARM)
+ {
+ error ("catch parameter declared %<auto%>");
+ type = error_mark_node;
+ }
else if (current_class_type && LAMBDA_TYPE_P (current_class_type))
{
if (cxx_dialect < cxx1y)
--
[PATCH] cpp0x/auto9.C: Downgrade expected error to expected pedwarn.
---
diff --git a/gcc/testsuite/g++.dg/cpp0x/auto9.C
b/gcc/testsuite/g++.dg/cpp0x/auto9.C
index 190bfa6..f357f2b 100644
--- a/gcc/testsuite/g++.dg/cpp0x/auto9.C
+++ b/gcc/testsuite/g++.dg/cpp0x/auto9.C
@@ -117,8 +117,8 @@ template <auto V = 4> struct G {}; // { dg-error
"auto" }
template <typename T> struct H { H (); ~H (); };
H<auto> h; // { dg-error "invalid" }
-void qq (auto); // { dg-error "auto" }
-void qr (auto*); // { dg-error "auto" }
+void qq (auto); // { dg-warning "auto" }
+void qr (auto*); // { dg-warning "auto" }
// PR c++/46145
typedef auto autot; // { dg-error "auto" }
--