diff options
Diffstat (limited to 'gcc/cp/pt.c')
-rw-r--r-- | gcc/cp/pt.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index dfc972870f4..076224c46df 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -5402,11 +5402,19 @@ convert_nontype_argument (tree type, tree expr, tsubst_flags_t complain) { if (complain & tf_error) { - error ("%qE is not a valid template argument for type %qT " - "because it is a non-constant expression", expr, type); - cxx_constant_value (expr); + int errs = errorcount, warns = warningcount; + expr = cxx_constant_value (expr); + if (errorcount > errs || warningcount > warns) + inform (EXPR_LOC_OR_HERE (expr), + "in template argument for type %qT ", type); + if (expr == error_mark_node) + return NULL_TREE; + /* else cxx_constant_value complained but gave us + a real constant, so go ahead. */ + gcc_assert (TREE_CODE (expr) == INTEGER_CST); } - return NULL_TREE; + else + return NULL_TREE; } } /* [temp.arg.nontype]/5, bullet 2 |