diff options
author | Jason Merrill <jason@redhat.com> | 2013-03-16 22:37:21 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2013-03-16 22:37:21 -0400 |
commit | b7df43cdb4108016f6cbf511a65194384792e34d (patch) | |
tree | 7f187a2ff1eec6fa08d81713a24ebb97e0426cb2 /gcc | |
parent | 57fcd4f4e4f12b1ede24f05385183d3f2dc7acfa (diff) | |
download | gcc-b7df43cdb4108016f6cbf511a65194384792e34d.zip gcc-b7df43cdb4108016f6cbf511a65194384792e34d.tar.gz gcc-b7df43cdb4108016f6cbf511a65194384792e34d.tar.bz2 |
re PR c++/56481 (endless loop compiling a C++ file)
PR c++/56481
* semantics.c (potential_constant_expression_1): Use of 'this' in
a non-constexpr function makes the expression not potentially
constant.
From-SVN: r196737
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/semantics.c | 7 |
2 files changed, 12 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 580208a..5b28025 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,10 @@ 2013-03-16 Jason Merrill <jason@redhat.com> + PR c++/56481 + * semantics.c (potential_constant_expression_1): Use of 'this' in + a non-constexpr function makes the expression not potentially + constant. + N3276 PR c++/52748 * cp-tree.h (tsubst_flags): Add tf_decltype. diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index efe09bb..20fe243 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -8497,6 +8497,13 @@ potential_constant_expression_1 (tree t, bool want_rval, tsubst_flags_t flags) STRIP_NOPS (x); if (is_this_parameter (x)) { + if (DECL_CONTEXT (x) + && !DECL_DECLARED_CONSTEXPR_P (DECL_CONTEXT (x))) + { + if (flags & tf_error) + error ("use of %<this%> in a constant expression"); + return false; + } if (want_rval && DECL_CONTEXT (x) && DECL_CONSTRUCTOR_P (DECL_CONTEXT (x))) { |