From: Roman Zhuykov Date: Fri, 29 Mar 2019 18:44:01 +0000 (+0000) Subject: opts-common.c (integral_argument): Set errno properly in one case. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7ad99f7d21983de63725701832e03d095842b3ae;p=gcc.git opts-common.c (integral_argument): Set errno properly in one case. * opts-common.c (integral_argument): Set errno properly in one case. * gcc.dg/diag-sanity.c: New test. From-SVN: r270022 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 76457ac956e..15b24087e28 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,7 @@ +2019-03-29 Roman Zhuykov + + * opts-common.c (integral_argument): Set errno properly in one case. + 2019-03-29 Martin Liska * doc/invoke.texi: Remove -Wchkp from documentation. diff --git a/gcc/opts-common.c b/gcc/opts-common.c index edbb3ac9b6d..8456dcc697b 100644 --- a/gcc/opts-common.c +++ b/gcc/opts-common.c @@ -205,8 +205,10 @@ integral_argument (const char *arg, int *err, bool byte_size_suffix) value = strtoull (arg, &end, 0); if (*end) { - /* errno is most likely EINVAL here. */ - *err = errno; + if (errno) + *err = errno; + else + *err = EINVAL; return -1; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 960a86508b0..9d6743d725a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2019-03-29 Roman Zhuykov + + * gcc.dg/diag-sanity.c: New test. + 2019-03-29 Marek Polacek PR c++/89871 diff --git a/gcc/testsuite/gcc.dg/diag-sanity.c b/gcc/testsuite/gcc.dg/diag-sanity.c new file mode 100644 index 00000000000..5e58d96633f --- /dev/null +++ b/gcc/testsuite/gcc.dg/diag-sanity.c @@ -0,0 +1,7 @@ +/* Verify that an invalid argument is diagnosed correcly. + { dg-do compile } + { dg-options "-fdiagnostics-minimum-margin-width=42xyz -flto-compression-level=2-O2" } */ + + +/* { dg-error "argument to '-fdiagnostics-minimum-margin-width=' should be a non-negative integer" "" { target *-*-* } 0 } + { dg-error "argument to '-flto-compression-level=' should be a non-negative integer" "" { target *-*-* } 0 } */