diff --git a/gcc/gcc-urlifier.cc b/gcc/gcc-urlifier.cc index be6459e8d7c..ff8c3f65ac5 100644 --- a/gcc/gcc-urlifier.cc +++ b/gcc/gcc-urlifier.cc @@ -26,6 +26,7 @@ along with GCC; see the file COPYING3. If not see #include "gcc-urlifier.h" #include "opts.h" #include "options.h" +#include "diagnostic-core.h" #include "selftest.h" namespace { @@ -208,7 +209,16 @@ gcc_urlifier::make_doc_url (const char *doc_url_suffix) if (!doc_url_suffix) return nullptr; - return concat (DOCUMENTATION_ROOT_URL, doc_url_suffix, nullptr); + char infix[32]; + /* On release branches, append to DOCUMENTATION_ROOT_URL the + subdirectory with documentation of the latest release made + from the branch. */ + if (BUILDING_GCC_MINOR != 0 && BUILDING_GCC_PATCHLEVEL <= 1U) + sprintf (infix, "gcc-%u.%u.0/", + BUILDING_GCC_MAJOR, BUILDING_GCC_MINOR); + else + infix[0] = '\0'; + return concat (DOCUMENTATION_ROOT_URL, infix, doc_url_suffix, nullptr); } } // anonymous namespace diff --git a/gcc/opts.cc b/gcc/opts.cc index 3333600e0ea..a90dc57f8b5 100644 --- a/gcc/opts.cc +++ b/gcc/opts.cc @@ -3761,7 +3761,19 @@ get_option_url (const diagnostic_context *, { label_text url_suffix = get_option_url_suffix (option_index, lang_mask); if (url_suffix.get ()) - return concat (DOCUMENTATION_ROOT_URL, url_suffix.get (), nullptr); + { + char infix[32]; + /* On release branches, append to DOCUMENTATION_ROOT_URL the + subdirectory with documentation of the latest release made + from the branch. */ + if (BUILDING_GCC_MINOR != 0 && BUILDING_GCC_PATCHLEVEL <= 1U) + sprintf (infix, "gcc-%u.%u.0/", + BUILDING_GCC_MAJOR, BUILDING_GCC_MINOR); + else + infix[0] = '\0'; + return concat (DOCUMENTATION_ROOT_URL, infix, url_suffix.get (), + nullptr); + } } return nullptr;