c++: Fix ICE with loop pragmas at class scope [PR126323]

cp_parser_pragma rejected GCC loop pragmas at namespace scope, but not
at class scope.  Consequently, it attempted to parse the following loop
as a statement while in a member-declaration context, leading to an ICE
when processing the loop initializer.

Accept these pragmas only in statement contexts.

gcc/cp/ChangeLog:

	PR c++/126323
	* parser.cc (cp_parser_pragma): Reject GCC loop pragmas outside
	statement contexts.

gcc/testsuite/ChangeLog:

	PR c++/126323
	* g++.dg/parse/pr126323.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
2 files changed