From bb9869d5a3e3a0f3673742ede7ea9bc325adbb4a Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Wed, 17 Jan 2018 17:51:25 +0000 Subject: C++: Fix crash in warn_for_memset within templates (PR c++/83814) gcc/c-family/ChangeLog: PR c++/83814 * c-common.c (fold_for_warn): Move to c/c-fold.c and cp/expr.c. gcc/c/ChangeLog: PR c++/83814 * c-fold.c (fold_for_warn): Move from c-common.c, reducing to just the C part. gcc/cp/ChangeLog: PR c++/83814 * expr.c (fold_for_warn): Move from c-common.c, reducing to just the C++ part. If processing a template, call fold_non_dependent_expr rather than fully folding. gcc/testsuite/ChangeLog: PR c++/83814 PR c++/83902 * g++.dg/wrappers/pr83814.C: New test case. * g++.dg/wrappers/pr83902.C: New test case. From-SVN: r256804 --- gcc/cp/expr.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'gcc/cp/expr.c') diff --git a/gcc/cp/expr.c b/gcc/cp/expr.c index da09ab8..49a17a6 100644 --- a/gcc/cp/expr.c +++ b/gcc/cp/expr.c @@ -315,3 +315,18 @@ mark_exp_read (tree exp) } } +/* Fold X for consideration by one of the warning functions when checking + whether an expression has a constant value. */ + +tree +fold_for_warn (tree x) +{ + /* C++ implementation. */ + + /* It's not generally safe to fully fold inside of a template, so + call fold_non_dependent_expr instead. */ + if (processing_template_decl) + return fold_non_dependent_expr (x); + + return c_fully_fold (x, /*for_init*/false, /*maybe_constp*/NULL); +} -- cgit v1.1