]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/56481 (endless loop compiling a C++ file)
authorJason Merrill <jason@redhat.com>
Sun, 17 Mar 2013 02:37:21 +0000 (22:37 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Sun, 17 Mar 2013 02:37:21 +0000 (22:37 -0400)
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
gcc/cp/semantics.c

index 580208a2ff4967c0ccf866ad57a8f987b6e0821a..5b28025defb7f8a775efd7d6223f05e3375019df 100644 (file)
@@ -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.
index efe09bb14b2511f9839123f4c54dd52bc17a1335..20fe2433777ce8de3ce95eb02bedf74cad9148b8 100644 (file)
@@ -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)))
              {