warnings are changed to errors

warnings are changed to errors

Is there a way to convert only specific warnings to errors ? With -warn errors all warnings are converted to errors and I only need some warnings to be converted to errors (-warn declarations)

Thanks in advance,

Albert

9 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.
Steve Lionel (Intel)'s picture

-diag-error number

where "number" is the number of the diagnostic you want forced as an error. It can also be a comma-separated list of diagnostic numbers.

Steve

Quoting - Steve Lionel (Intel)

-diag-error number

where "number" is the number of the diagnostic you want forced as an error. It can also be a comma-separated list of diagnostic numbers.

Thanks for the answer, but where can I find the numbers associated with the error messages ?

Best regards,

Albert

The number comes from the warning you're trying to elevate to an error.

In the example below, *only* warning #6717 is elevated to an error using the -diag-error option suggested.

$ ifort -V -c -std -warn all sample.f
Intel Fortran Intel 64 Compiler Professional for applications running on Intel 64, Version 11.1 Build 20091130 Package ID: l_cprof_p_11.1.064
Copyright (C) 1985-2009 Intel Corporation. All rights reserved.

Intel Fortran 11.1-2649
sample.f(1): warning #7373: Fixed form source is an obsolescent feature in Fortran 2003.
program sample
^
sample.f(7): warning #6717: This name has not been given an explicit type. [A]
a = 1.d0
------^
sample.f(8): warning #6717: This name has not been given an explicit type. [C]
c = 0.d0
------^
sample.f(9): warning #6717: This name has not been given an explicit type. [D]
d = a/c
------^

Now use -diag-error number to elevate only warning #6717 to an error. Notice that warning #7373 is unaffected.

$ ifort -V -c -std -warn all -diag-error 6717 sample.f
Intel Fortran Intel 64 Compiler Professional for applications running on Intel 64, Version 11.1 Build 20091130 Package ID: l_cprof_p_11.1.064
Copyright (C) 1985-2009 Intel Corporation. All rights reserved.

Intel Fortran 11.1-2649
sample.f(1): warning #7373: Fixed form source is an obsolescent feature in Fortran 2003.
program sample
^
sample.f(7): error #6717: This name has not been given an explicit type. [A]
a = 1.d0
------^
sample.f(8): error #6717: This name has not been given an explicit type. [C]
c = 0.d0
------^
sample.f(9): error #6717: This name has not been given an explicit type. [D]
d = a/c
------^

Quoting - Kevin Davis (Intel)

The number comes from the warning you're trying to elevate to an error.

In the example below, *only* warning #6717 is elevated to an error using the -diag-error option suggested.

$ ifort -V -c -std -warn all sample.f
Intel Fortran Intel 64 Compiler Professional for applications running on Intel 64, Version 11.1 Build 20091130 Package ID: l_cprof_p_11.1.064
Copyright (C) 1985-2009 Intel Corporation. All rights reserved.

Intel Fortran 11.1-2649
sample.f(1): warning #7373: Fixed form source is an obsolescent feature in Fortran 2003.
program sample
^
sample.f(7): warning #6717: This name has not been given an explicit type. [A]
a = 1.d0
------^
sample.f(8): warning #6717: This name has not been given an explicit type. [C]
c = 0.d0
------^
sample.f(9): warning #6717: This name has not been given an explicit type. [D]
d = a/c
------^

Now use -diag-error number to elevate only warning #6717 to an error. Notice that warning #7373 is unaffected.

$ ifort -V -c -std -warn all -diag-error 6717 sample.f
Intel Fortran Intel 64 Compiler Professional for applications running on Intel 64, Version 11.1 Build 20091130 Package ID: l_cprof_p_11.1.064
Copyright (C) 1985-2009 Intel Corporation. All rights reserved.

Intel Fortran 11.1-2649
sample.f(1): warning #7373: Fixed form source is an obsolescent feature in Fortran 2003.
program sample
^
sample.f(7): error #6717: This name has not been given an explicit type. [A]
a = 1.d0
------^
sample.f(8): error #6717: This name has not been given an explicit type. [C]
c = 0.d0
------^
sample.f(9): error #6717: This name has not been given an explicit type. [D]
d = a/c
------^

Thank you for the answer, it was clear to me how to work with the numbers but I didn't know where to get them.
I'm still using version 10.1.012 compiler. I also tried the 11.1-2620 (build 10081012) version.
With version 10 I don't get the warning numbers and also the -diag-error 6717 does not promote this warning to an error/
When using the 11.1 compiler I get the warning number and it is promoted to an error.

Is this a new feature in the 11.1 compiler ?
Is there a lis of the 10.1 warning numbers (if the feature -dag-error works in this version).

Best Regards,

Albert

No, it is not a new feature to 11.x but there were many problems fixed in 11.x. This is part of the "static verifier" feature added back in the 10.x release, however, there were significant issues with the feature in 10.x release.

I haven't had much success using the feature before 11.x nor am I aware of a list of 10.1 warning #s but you can search only Knowledge Base articles and find diagnostic #s for diagnostics currently being documented. For example, diagnostic #6717 can be found (here) using a text search for keywords from the message. A number of Fortran specific diagnostics can also be found by searching for "Diagnostic Fortran".

Quoting - Kevin Davis (Intel)

No, it is not a new feature to 11.x but there were many problems fixed in 11.x. This is part of the "static verifier" feature added back in the 10.x release, however, there were significant issues with the feature in 10.x release.

I haven't had much success using the feature before 11.x nor am I aware of a list of 10.1 warning #s but you can search only Knowledge Base articles and find diagnostic #s for diagnostics currently being documented. For example, diagnostic #6717 can be found (here) using a text search for keywords from the message. A number of Fortran specific diagnostics can also be found by searching for "Diagnostic Fortran".

Thank you for the answer. So the best way is to use the 11.1 compiler.
(I'm aware of some issues with the static verifier in version 10, I submited some problem reports on it).

Thank you for your effort.

Best Regards,

Albert

Steve Lionel (Intel)'s picture

Diagnostics such as the ones you want to change, issued by the compiler itself, did not have numbers until version 11.0. In prior versions, there is no way to change the severity of individual Fortran diagnostics.

Kevin is correct that the concept of diagnostic numbers and the control over them was first introduced with the Static Verifier (now Source Checker) feature.

Steve

Quoting - Steve Lionel (Intel)
Diagnostics such as the ones you want to change, issued by the compiler itself, did not have numbers until version 11.0. In prior versions, there is no way to change the severity of individual Fortran diagnostics.

Kevin is correct that the concept of diagnostic numbers and the control over them was first introduced with the Static Verifier (now Source Checker) feature.

Thanks a lot for the answers.

Best Regards,

Albert

Login to leave a comment.