From b7df43cdb4108016f6cbf511a65194384792e34d Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Sat, 16 Mar 2013 22:37:21 -0400 Subject: 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 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/semantics.c | 7 +++++++ 2 files changed, 12 insertions(+) (limited to 'gcc') 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 + 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 % in a constant expression"); + return false; + } if (want_rval && DECL_CONTEXT (x) && DECL_CONSTRUCTOR_P (DECL_CONTEXT (x))) { -- cgit v1.1