c++: Reject identifier label in constexpr [PR97846]
authorMarek Polacek <polacek@redhat.com>
Tue, 17 Nov 2020 00:59:35 +0000 (19:59 -0500)
committerMarek Polacek <polacek@redhat.com>
Sat, 21 Nov 2020 21:08:33 +0000 (16:08 -0500)
commit6f20c42cc162ac3725584547ab4933bae4c78665
treea32c6e9475135528dc07fdd8cfd68404d99cdbf1
parent0999f26098598fe0a499c5b79ad23678ccfe583a
c++: Reject identifier label in constexpr [PR97846]

[dcl.constexpr]/3 says that the function-body of a constexpr function
shall not contain an identifier label, but we aren't enforcing that.

This patch implements that.  Of course, we can't reject artificial
labels.

gcc/cp/ChangeLog:

PR c++/97846
* constexpr.c (potential_constant_expression_1): Reject
LABEL_EXPRs that use non-artifical LABEL_DECLs.

gcc/testsuite/ChangeLog:

PR c++/97846
* g++.dg/cpp1y/constexpr-label.C: New test.
gcc/cp/constexpr.c
gcc/testsuite/g++.dg/cpp1y/constexpr-label.C [new file with mode: 0644]