/* Take any action which is expected to happen after the diagnostic is written out. This function does not always return. */ static void diagnostic_action_after_output (diagnostic_context *context, diagnostic_info *diagnostic) { switch (diagnostic->kind) { case DK_DEBUG: case DK_NOTE: case DK_ANACHRONISM: case DK_WARNING: break; case DK_ERROR: case DK_SORRY: if (context->abort_on_error) real_abort (); if (context->fatal_errors) { fnotice (stderr, "compilation terminated due to -Wfatal-errors.\n"); diagnostic_finish (context); exit (FATAL_EXIT_CODE); } if (context->max_errors != 0 && ((unsigned) (diagnostic_kind_count (context, DK_ERROR) + diagnostic_kind_count (context, DK_SORRY)) >= context->max_errors)) { fnotice (stderr, "compilation terminated due to -fmax-errors=%u.\n", context->max_errors); diagnostic_finish (context); exit (FATAL_EXIT_CODE); } break; case DK_ICE: if (context->abort_on_error) real_abort (); fnotice (stderr, "Please submit a full bug report,\n" "with preprocessed source if appropriate.\n" "See %s for instructions.\n", bug_report_url); exit (ICE_EXIT_CODE); case DK_FATAL: if (context->abort_on_error) real_abort (); diagnostic_finish (context); fnotice (stderr, "compilation terminated.\n"); exit (FATAL_EXIT_CODE); default: gcc_unreachable (); } }
const char* avr_devicespecs_file (int argc, const char **argv) { const char *mmcu = NULL; #ifdef DEBUG_SPECS if (verbose_flag) fnotice (stderr, "Running spec function '%s' with %d args\n\n", __FUNCTION__, argc); #endif switch (argc) { case 0: fatal_error (input_location, "bad usage of spec function %qs", "device-specs-file"); return X_NODEVLIB; case 1: if (0 == strcmp ("device-specs", argv[0])) { /* FIXME: This means "device-specs%s" from avr.h:DRIVER_SELF_SPECS has not been resolved to a path. That case can occur when the c++ testsuite is run from the build directory. DejaGNU's libgloss.exp:get_multilibs runs $compiler without -B, i.e.runs xgcc without specifying a prefix. Without any prefix, there is no means to find out where the specs files might be located. get_multilibs runs xgcc --print-multi-lib, hence we don't actually need information form a specs file and may skip it here. */ return X_NODEVLIB; } mmcu = AVR_MMCU_DEFAULT; break; default: mmcu = argv[1]; // Allow specifying the same MCU more than once. for (int i = 2; i < argc; i++) if (0 != strcmp (mmcu, argv[i])) { error ("specified option %qs more than once", "-mmcu"); return X_NODEVLIB; } break; } // Filter out silly -mmcu= arguments like "foo bar". for (const char *s = mmcu; *s; s++) if (!ISALNUM (*s) && '-' != *s && '_' != *s) { error ("strange device name %qs after %qs: bad character %qc", mmcu, "-mmcu=", *s); return X_NODEVLIB; } return concat ("-specs=device-specs", dir_separator_str, "specs-", mmcu, "%s" #if defined (WITH_AVRLIBC) " %{mmcu=avr*:" X_NODEVLIB "} %{!mmcu=*:" X_NODEVLIB "}", #else " " X_NODEVLIB, #endif NULL); }
const char* avr_devicespecs_file (int argc, const char **argv) { char *specfile_name; const char *mmcu = NULL; #ifdef DEBUG_SPECS if (verbose_flag) fnotice (stderr, "Running spec function '%s' with %d args\n\n", __FUNCTION__, argc); #endif switch (argc) { case 0: fatal_error (input_location, "bad usage of spec function %qs", "device-specs-file"); return X_NODEVLIB; case 1: mmcu = AVR_MMCU_DEFAULT; break; default: mmcu = argv[1]; // Allow specifying the same MCU more than once. for (int i = 2; i < argc; i++) if (0 != strcmp (mmcu, argv[i])) { error ("specified option %qs more than once", "-mmcu"); return X_NODEVLIB; } break; } specfile_name = concat (argv[0], dir_separator_str, "specs-", mmcu, NULL); #ifdef DEBUG_SPECS if (verbose_flag) fnotice (stderr, "'%s': mmcu='%s'\n'%s': specfile='%s'\n\n", __FUNCTION__, mmcu, __FUNCTION__, specfile_name); #endif // Filter out silly -mmcu= arguments like "foo bar". for (const char *s = mmcu; *s; s++) if (!ISALNUM (*s) && '-' != *s && '_' != *s) { error ("strange device name %qs after %qs: bad character %qc", mmcu, "-mmcu=", *s); return X_NODEVLIB; } if (/* When building / configuring the compiler we might get a relative path as supplied by "-B.". Assume that the specs file exists and MCU is a core, not a proper device then, i.e. we have "-mmcu=avr*". */ (0 == strncmp (mmcu, "avr", strlen ("avr")) && specfile_name[0] == '.') /* vanilla */ || (IS_ABSOLUTE_PATH (specfile_name) && !access (specfile_name, R_OK))) { return concat ("-specs=device-specs", dir_separator_str, "specs-", mmcu, // Use '%s' instead of the expanded specfile_name. This // is the easiest way to handle pathes containing spaces. "%s", #if defined (WITH_AVRLIBC) " %{mmcu=avr*:" X_NODEVLIB "} %{!mmcu=*:" X_NODEVLIB "}", #else " " X_NODEVLIB, #endif NULL); } return avr_diagnose_devicespecs_error (mmcu, specfile_name); }