aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorAdam Butcher <adam@jessamine.co.uk>2013-09-12 19:54:42 +0100
committerAdam Butcher <abutcher@gcc.gnu.org>2013-09-12 19:54:42 +0100
commit1c1880fcc6ca93f7ac589122448b605f4a3617af (patch)
treea6f6b2c23f5262d18787189b8876f20b0297dd79 /gcc
parent84f6d9fa3de366017eafa07730e2ee9a1886f3d7 (diff)
downloadgcc-1c1880fcc6ca93f7ac589122448b605f4a3617af.zip
gcc-1c1880fcc6ca93f7ac589122448b605f4a3617af.tar.gz
gcc-1c1880fcc6ca93f7ac589122448b605f4a3617af.tar.bz2
Support decl instantiation in function-local templates.
* pt.c (instantiate_decl): Save/restore cp_unevaluated_operand and c_inhibit_evaluation_warnings. Reset if instantiating within a function-local template. From-SVN: r202538
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/pt.c13
2 files changed, 17 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 9c99970..cbad022 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2013-09-12 Adam Butcher <adam@jessamine.co.uk>
+
+ * pt.c (instantiate_decl): Save/restore cp_unevaluated_operand and
+ c_inhibit_evaluation_warnings. Reset if instantiating within a
+ function-local template.
+
2013-09-12 Paolo Carlini <paolo.carlini@oracle.com>
* semantics.c (finish_pseudo_destructor_expr): Add location_t
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index e4ae4b7..3ae679a 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -18947,6 +18947,8 @@ instantiate_decl (tree d, int defer_ok,
tree gen_tmpl;
bool pattern_defined;
location_t saved_loc = input_location;
+ int saved_unevaluated_operand = cp_unevaluated_operand;
+ int saved_inhibit_evaluation_warnings = c_inhibit_evaluation_warnings;
bool external_p;
tree fn_context;
bool nested;
@@ -19158,8 +19160,13 @@ instantiate_decl (tree d, int defer_ok,
nested = (current_function_decl != NULL_TREE);
if (!fn_context)
push_to_top_level ();
- else if (nested)
- push_function_context ();
+ else
+ {
+ if (nested)
+ push_function_context ();
+ cp_unevaluated_operand = 0;
+ c_inhibit_evaluation_warnings = 0;
+ }
/* Mark D as instantiated so that recursive calls to
instantiate_decl do not try to instantiate it again. */
@@ -19283,6 +19290,8 @@ instantiate_decl (tree d, int defer_ok,
out:
input_location = saved_loc;
+ cp_unevaluated_operand = saved_unevaluated_operand;
+ c_inhibit_evaluation_warnings = saved_inhibit_evaluation_warnings;
pop_deferring_access_checks ();
pop_tinst_level ();