cp_lexer_consume_token (parser->lexer);
cp_parser_require_pragma_eol (parser, token);
- if ((mp_state != MP_PURVIEW && mp_state != MP_PURVIEW_IMPORTS)
+ if (!(mp_state == MP_PURVIEW || mp_state == MP_PURVIEW_IMPORTS)
|| !module_interface_p () || module_partition_p ())
error_at (token->location,
- "private module fragment not permitted here");
+ "private module fragment only permitted in purview"
+ " of module interface or partition");
else
{
mp_state = MP_PRIVATE_IMPORTS;
sorry_at (token->location, "private module fragment");
}
}
- else if (mp_state != MP_FIRST && mp_state != MP_GLOBAL)
+ else if (!(mp_state == MP_FIRST || mp_state == MP_GLOBAL))
{
- error_at (token->location, "module-declaration not permitted here");
+ /* Neither the first declaration, nor in a GMF. */
+ error_at (token->location, "module-declaration only permitted as first"
+ " declaration, or ending a global module fragment");
skip_eol:
cp_parser_skip_to_pragma_eol (parser, token);
}
import frist; // { dg-error {cannot import module.* in its own purview} }
-module foo.second; // { dg-error "not permitted here" }
+module foo.second; // { dg-error "only permitted as" }
namespace Foo
{
-module third; // { dg-error "not permitted here" }
+module third; // { dg-error "only permitted as" }
}
struct Baz
module fifth; // { dg-error "expected" }
}
-module a.; // { dg-error "not permitted" }
+module a.; // { dg-error "only permitted as" }
// { dg-prune-output "not writing module" }
// { dg-additional-options "-fmodules-ts" }
int k;
-module frob; // { dg-error "not permitted" }
+module frob; // { dg-error "only permitted as" }
// { dg-prune-output "failed to read" }
// { dg-prune-output "fatal error:" }
// { dg-prune-output "compilation terminated" }