diff options
author | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-10-20 02:48:51 +0000 |
---|---|---|
committer | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-10-20 02:48:51 +0000 |
commit | a36e5e5ee5c0e7ce7d5db356f4bfb8adfe7cebe8 (patch) | |
tree | ce34d7922020e02b9e9d7346c70ded9a6f9f13c7 /gcc/cp/pt.c | |
parent | f16ed232f63165d926986d482708ebf464a04108 (diff) | |
download | gcc-a36e5e5ee5c0e7ce7d5db356f4bfb8adfe7cebe8.tar.gz |
Implement N4268, Do constant evaluation of all non-type template args.
gcc/c-family/
* c-cppbuiltin.c (c_cpp_builtins): Define
__cpp_nontype_template_args.
gcc/cp/
* parser.c (cp_parser_template_argument): For C++1z just parse a
constant-expression.
* pt.c (convert_nontype_argument): For C++1z always call
maybe_constant_value.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@229019 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/pt.c')
-rw-r--r-- | gcc/cp/pt.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 14a5ddd9bb3..142245ad8e0 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -6233,6 +6233,17 @@ convert_nontype_argument (tree type, tree expr, tsubst_flags_t complain) CONSTRUCTOR. */; else if (INTEGRAL_OR_ENUMERATION_TYPE_P (type)) expr = maybe_constant_value (expr); + else if (cxx_dialect >= cxx1z) + { + if (TREE_CODE (type) != REFERENCE_TYPE) + expr = maybe_constant_value (expr); + else if (REFERENCE_REF_P (expr)) + { + expr = TREE_OPERAND (expr, 0); + expr = maybe_constant_value (expr); + expr = convert_from_reference (expr); + } + } else if (TYPE_PTR_OR_PTRMEM_P (type)) { tree folded = maybe_constant_value (expr); |