diff options
author | David Malcolm <dmalcolm@redhat.com> | 2018-01-17 17:51:25 +0000 |
---|---|---|
committer | David Malcolm <dmalcolm@gcc.gnu.org> | 2018-01-17 17:51:25 +0000 |
commit | bb9869d5a3e3a0f3673742ede7ea9bc325adbb4a (patch) | |
tree | 4ad7e64ad7b745b5bef09ce376f20f5235b2d803 /gcc/cp/expr.c | |
parent | d2edcd7083601bc08789787331399624b85b843b (diff) | |
download | gcc-bb9869d5a3e3a0f3673742ede7ea9bc325adbb4a.zip gcc-bb9869d5a3e3a0f3673742ede7ea9bc325adbb4a.tar.gz gcc-bb9869d5a3e3a0f3673742ede7ea9bc325adbb4a.tar.bz2 |
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
Diffstat (limited to 'gcc/cp/expr.c')
-rw-r--r-- | gcc/cp/expr.c | 15 |
1 files changed, 15 insertions, 0 deletions
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); +} |