@@ -4287,6 +4287,48 @@ kind indicates which of the above is being processed.
42874287} /* process_gnu_options_pragma */
42884288
42894289
4290+ static a_boolean process_gnu_diagnostic_pragma (a_pending_pragma_ptr ppp )
4291+ /*
4292+ Handle "#pragma GCC diagnostic push/pop" (GCC 4.6 and later) and
4293+ "#pragma GCC diagnostic kind "option"", where kind is "error", "warning",
4294+ "ignored", "fatal" (clang only), or "ignored_attributes" (GCC 12 and later).
4295+ The pragmas are only accepted: they do not affect the front end's own
4296+ diagnostics, and (as in GCC) trailing text is ignored. Return FALSE if the
4297+ form is not recognized by the compiler being emulated.
4298+ */
4299+ {
4300+ a_boolean recognized = FALSE;
4301+
4302+ /* Skip the "diagnostic" identifier. */
4303+ (void )get_token ();
4304+ if (curr_token == tok_identifier ) {
4305+ a_const_char * str = locator_for_curr_id .symbol_header -> identifier ;
4306+ if (gnu_version >= 40600 &&
4307+ (strcmp (str , "push" ) == 0 || strcmp (str , "pop" ) == 0 )) {
4308+ recognized = TRUE;
4309+ } else if (strcmp (str , "error" ) == 0 ||
4310+ strcmp (str , "warning" ) == 0 ||
4311+ strcmp (str , "ignored" ) == 0 ||
4312+ (clang_mode && strcmp (str , "fatal" ) == 0 ) ||
4313+ (gnu_version >= 120000 &&
4314+ strcmp (str , "ignored_attributes" ) == 0 )) {
4315+ recognized = TRUE;
4316+ (void )get_token ();
4317+ if (curr_token != tok_string_literal ||
4318+ !is_normal_character_kind (const_for_curr_token .character_kind )) {
4319+ /* The option (or attribute list) is missing. Only a string literal
4320+ of plain char type is accepted. */
4321+ pos_warning (ec_exp_string_literal , & error_position );
4322+ } /* if */
4323+ } /* if */
4324+ } /* if */
4325+ if (recognized ) {
4326+ ppp -> variant .gcc .kind = (a_gcc_pragma_kind )gcc_pk_diagnostic ;
4327+ } /* if */
4328+ return recognized ;
4329+ } /* process_gnu_diagnostic_pragma */
4330+
4331+
42904332void gcc_pragma (a_pending_pragma_ptr ppp )
42914333/*
42924334Process a "#pragma GCC ..." construct.
@@ -4318,6 +4360,9 @@ Process a "#pragma GCC ..." construct.
43184360 process_gnu_options_pragma (ppp , (a_gcc_pragma_kind )gcc_pk_pop_options );
43194361 } else if (gnu_version >= 40400 && strcmp (str , "reset_options" ) == 0 ) {
43204362 process_gnu_options_pragma (ppp , (a_gcc_pragma_kind )gcc_pk_reset_options );
4363+ } else if (strcmp (str , "diagnostic" ) == 0 ) {
4364+ ignore_in_back_end = FALSE;
4365+ recognized = process_gnu_diagnostic_pragma (ppp );
43214366#if GNU_VECTOR_TYPES_ALLOWED && BUILTIN_FUNCTIONS_ENABLED
43224367 } else if (target_is_arm_based () && target_is_64_bits () &&
43234368 strcmp (str , "aarch64" ) == 0 ) {
0 commit comments