aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2015-12-06 23:34:57 -0500
committerJason Merrill <jason@gcc.gnu.org>2015-12-06 23:34:57 -0500
commit19dedccfc36a34b843292e6493c7ffd429673de2 (patch)
treebf18eed02d681288b0f674e475652125572c8032
parentaabdb83166b53a13956071f0e01f841a184340f7 (diff)
downloadgcc-19dedccfc36a34b843292e6493c7ffd429673de2.zip
gcc-19dedccfc36a34b843292e6493c7ffd429673de2.tar.gz
gcc-19dedccfc36a34b843292e6493c7ffd429673de2.tar.bz2
Fix template/ref1.C, nontype15.C, addr-builtin1.C with -std=c++1z.
* parser.c (cp_parser_template_argument): Handle references in C++1z mode. * constexpr.c (potential_constant_expression_1): Don't error about TREE_THIS_VOLATILE on declarations. [COMPONENT_REF]: Don't consider the object if we're dealing with an overloaded function. From-SVN: r231351
-rw-r--r--gcc/cp/ChangeLog7
-rw-r--r--gcc/cp/constexpr.c4
-rw-r--r--gcc/cp/parser.c11
-rw-r--r--gcc/testsuite/g++.dg/template/nontype8.C2
4 files changed, 21 insertions, 3 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 310cdba..1fdbe05 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,12 @@
2015-12-06 Jason Merrill <jason@redhat.com>
+ * parser.c (cp_parser_template_argument): Handle references in
+ C++1z mode.
+ * constexpr.c (potential_constant_expression_1): Don't error about
+ TREE_THIS_VOLATILE on declarations.
+ [COMPONENT_REF]: Don't consider the object if we're dealing with
+ an overloaded function.
+
* constraint.cc (strictly_subsumes): New.
* cp-tree.h: Declare it.
* pt.c (process_partial_specialization): Use it instead of
diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
index 42e9902..208f43b 100644
--- a/gcc/cp/constexpr.c
+++ b/gcc/cp/constexpr.c
@@ -4130,7 +4130,7 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict,
return false;
if (t == NULL_TREE)
return true;
- if (TREE_THIS_VOLATILE (t))
+ if (TREE_THIS_VOLATILE (t) && !DECL_P (t))
{
if (flags & tf_error)
error ("expression %qE has side-effects", t);
@@ -4345,6 +4345,8 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict,
of literal type or of pointer to literal type. */
/* This test would be redundant, as it follows from the
postfix-expression being a potential constant expression. */
+ if (type_unknown_p (t))
+ return true;
return RECUR (TREE_OPERAND (t, 0), want_rval);
case EXPR_PACK_EXPANSION:
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 85f6cc1..1c7b1d5 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -15364,7 +15364,16 @@ cp_parser_template_argument (cp_parser* parser)
because the argument could really be a type-id. */
if (maybe_type_id)
cp_parser_parse_tentatively (parser);
- argument = cp_parser_constant_expression (parser);
+
+ if (cxx_dialect <= cxx14)
+ argument = cp_parser_constant_expression (parser);
+ else
+ {
+ /* With C++17 generalized non-type template arguments we need to handle
+ lvalue constant expressions, too. */
+ argument = cp_parser_assignment_expression (parser);
+ require_potential_constant_expression (argument);
+ }
if (!maybe_type_id)
return argument;
diff --git a/gcc/testsuite/g++.dg/template/nontype8.C b/gcc/testsuite/g++.dg/template/nontype8.C
index d2976df..d31f892 100644
--- a/gcc/testsuite/g++.dg/template/nontype8.C
+++ b/gcc/testsuite/g++.dg/template/nontype8.C
@@ -8,6 +8,6 @@ struct S { int m; static int s; } s;
X<&a[2]> x3; // { dg-error "" } address of array element
X<&s.m> x4; // { dg-error "" } address of non-static member
-X<&s.s> x5; // { dg-error "" } &S::s must be used
+X<&s.s> x5; // { dg-error "" "" { target { ! c++1z } } } &S::s must be used
X<&S::s> x6; // OK: address of static member