From: Jason Merrill Date: Sun, 17 Mar 2013 02:37:21 +0000 (-0400) Subject: re PR c++/56481 (endless loop compiling a C++ file) X-Git-Tag: releases/gcc-4.9.0~7029 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b7df43cdb4108016f6cbf511a65194384792e34d;p=thirdparty%2Fgcc.git 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 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 580208a2ff49..5b28025defb7 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 efe09bb14b25..20fe2433777c 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))) {