You can hook into registration_error
and check if the user’s email is under your specified domain or not:
add_filter( 'registration_errors', 'user_email_checker', 10, 3 );
function user_email_checker( $errors, $sanitized_user_login, $user_email ) {
if ( !preg_match('#[@.]gmail.com$#i', $user_email ) {
$errors->add( 'invalid_email', __( 'ERROR: Only "gmail.com" email address allowed.' ) );
}
return $errors;
}
This way you don’t have to deal with the core directly.
Further readings at : WordPress Codex.