#include "defs.h"
#include "producer.h"
#include "gdbsupport/selftest.h"
+#include <regex>
/* See producer.h. */
bool
producer_is_icc (const char *producer, int *major, int *minor)
{
- if (producer == NULL || !startswith (producer, "Intel(R)"))
+ std::regex i_re ("Intel\\(R\\)");
+ std::cmatch i_m;
+ if ((producer == nullptr) || !std::regex_search (producer, i_m, i_re))
return false;
/* Prepare the used fields. */
int maj, min;
- if (major == NULL)
+ if (major == nullptr)
major = &maj;
- if (minor == NULL)
+ if (minor == nullptr)
minor = &min;
*minor = 0;
*major = 0;
- /* Consumes the string till a "Version" is found. */
- const char *cs = strstr (producer, "Version");
- if (cs != NULL)
- {
- cs = skip_to_space (cs);
-
- int intermediate = 0;
- int nof = sscanf (cs, "%d.%d.%d.%*d", major, &intermediate, minor);
-
- /* Internal versions are represented only as MAJOR.MINOR, where
- minor is usually 0.
- Public versions have 3 fields as described with the command
- above. */
- if (nof == 3)
- return true;
-
- if (nof == 2)
- {
- *minor = intermediate;
- return true;
- }
- }
+ std::regex re ("[0-9]+\\.[0-9]+");
+ std::cmatch version;
- static bool warning_printed = false;
- /* Not recognized as Intel, let the user know. */
- if (!warning_printed)
+ if (std::regex_search (producer, version, re))
{
- warning (_("Could not recognize version of Intel Compiler in: \"%s\""),
- producer);
- warning_printed = true;
+ sscanf (version.str ().c_str (), "%d.%d", major, minor);
+ return true;
}
+
return false;
}
}
{
- static const char extern_f_14_1[] = "\
+ static const char extern_f_14_0[] = "\
Intel(R) Fortran Intel(R) 64 Compiler XE for applications running on \
Intel(R) 64, \
Version 14.0.1.074 Build 20130716";
int major = 0, minor = 0;
- SELF_CHECK (producer_is_icc (extern_f_14_1, &major, &minor)
- && major == 14 && minor == 1);
- SELF_CHECK (!producer_is_gcc (extern_f_14_1, &major, &minor));
+ SELF_CHECK (producer_is_icc (extern_f_14_0, &major, &minor)
+ && major == 14 && minor == 0);
+ SELF_CHECK (!producer_is_gcc (extern_f_14_0, &major, &minor));
}
{
extern int producer_is_gcc (const char *producer, int *major, int *minor);
/* Returns true if the given PRODUCER string is Intel or false
- otherwise. Sets the MAJOR and MINOR versions when not NULL.
-
- Internal and external ICC versions have to be taken into account.
- PRODUCER strings for internal releases are slightly different than
- for public ones. Internal releases have a major release number and
- 0 as minor release. External releases have 4 fields, 3 of them are
- not 0 and only two are of interest, major and update.
-
- Examples are:
-
- Public release:
- "Intel(R) Fortran Intel(R) 64 Compiler XE for applications
- running on Intel(R) 64, Version 14.0.1.074 Build 20130716";
- "Intel(R) C++ Intel(R) 64 Compiler XE for applications
- running on Intel(R) 64, Version 14.0.1.074 Build 20130716";
-
- Internal releases:
- "Intel(R) C++ Intel(R) 64 Compiler for applications
- running on Intel(R) 64, Version 18.0 Beta ....". */
+ otherwise. Sets the MAJOR and MINOR versions when not NULL. */
extern bool producer_is_icc (const char *producer, int *major, int *minor);
/* Returns true if the given PRODUCER string is LLVM (clang/flang) or