2.3.15. Diagnostic messages

The ARM compiler issues messages about potential portability problems and other hazards. This section describes compiler options that you can use to:

Note

The previous release of RVCT supported old compiler options to help you to migrate your message options to the new release. However, these options are now obsolete and are no longer supported. See Mapping old compiler options to the new release for details.

This section describes:

Severity of diagnostic messages

Diagnostic messages have an associated severity, as described in Table 2.6.

Table 2.6. Severity of diagnostic messages

SeverityDescription
Internal error

Internal errors indicate an internal problem with the compiler. Contact your supplier with the details listed in Feedback on RealView Developer Kit.

Error

Errors indicate problems that cause the compilation to stop. These errors include command line errors, internal errors, missing include files, and violations in the syntactic or semantic rules of the C or C++ language. If multiple source files are specified, then no further source files are compiled. For example:

Error: #65: expected a ";"

Warning

Warnings indicate unusual conditions in your code that might indicate a problem. Compilation continues, and object code is generated unless any further problems with an Error severity are detected. For example:

Warning: #1293-D: assignment in condition

Remark

Remarks indicate common, but sometimes unconventional, use of C or C++. These diagnostics are not displayed by default. Compilation continues, and object code is generated unless any further problems with an Error severity are detected. For example:

#940-D: missing return statement at end of non-void function "main"

Controlling the output of diagnostic messages

These options enable you to control the output of diagnostic messages:

--brief_diagnostics --no_brief_diagnostics

Enables or disables a mode where a shorter form of the diagnostic output is used. When enabled, the original source line is not displayed and the error message text is not wrapped when it is too long to fit on a single line. The default is --no_brief_diagnostics.

--diag_style {arm|ide}

Specifies the style used to display diagnostic messages:

arm

Display messages using the ARM compiler style. This is the default if --diag_style is not specified. For example:


"test.c", line 352: Warning:  #177-D: variable "temp" was declared but never referenced
ide

Include the line number and character count for the line that is in error. These values are displayed in parentheses. For example:


test.c(352,10) : Warning  #177-D: variable "temp" was declared but never referenced
--errors efile

Redirects the output of diagnostic messages from stderr to the specified file efile. This option is useful on systems where output redirection of files is not well supported.

Diagnostics that relate to problems with the command options are not redirected. For example, if you type an option name incorrectly. However, if you specify an incorrect argument to an option (for example, --cpu 999), the related diagnostic is redirected to the specified efile.

--remarks

Causes the compiler to issue remark messages. Remarks are not issued by default.

--wrap_diagnostics --no_wrap_diagnostics

Enables or disables the wrapping of error message text when it is too long to fit on a single line.

Changing the severity of diagnostic messages

These options enable you to change the diagnostic severity of all remarks and warnings, and a limited number of errors:

--diag_error tag[, tag, ...]

Sets the diagnostic messages that have the specified tag(s) to Error severity.

--diag_remark tag[, tag, ... ]

Sets the diagnostic messages that have the specified tag(s) to Remark severity.

--diag_warning tag[, tag, ...]

Sets the diagnostic messages that have the specified tag(s) to Warning severity.

These options require a comma-separated list of error message numbers that specifies the messages that must be changed. For example, you might want to change the following warning message to Remark severity, because remarks are not displayed by default:


Warning:  #1293-D: assignment in condition - give arg types

To do this, use the following command:


armcc --diag_remark 1293 ...

Note

These options also have pragma equivalents. See Pragmas controlling diagnostic messages for details.

The following diagnostic messages can be changed:

  • Messages with the number format #nnnn-D, for example:

    
    Warning:  #1293-D: assignment in condition - give arg types
    
  • Warning messages with the number format CnnnnW, for example:

    
    Warning: C2874W: y may be used before being set
    

Suppressing diagnostic messages

This option enables you to suppress diagnostic messages:

--diag_suppress tag[, tag, ...]

This option disables all diagnostic messages that have the specified tag(s).

This option requires a comma-separated list of diagnostic message numbers that specifies the messages that must be suppressed. For example, to suppress the warning messages that have numbers 1293 and 187, use the following command:


armcc --diag_suppress 1293,187 ...

In some circumstances, the compiler issues old-style warning messages, as well as new-style messages. For example, the compiler might issue the following warnings when compiling inline assembly code:


Warning:  #1287-D: LDM/STM instruction may be expanded
Warning: C2874W: y may be used before being set

To suppress both of these messages, specify only the numerical part of the warning code, for example:


armcc --diag_suppress 1287,2874 ...

Note

This option also has a pragma equivalent. See Pragmas controlling diagnostic messages for details.

Suppressing warning messages with the -W option

The -W option suppresses all warnings.

Exit status codes and termination messages

If the compiler detects any warnings or errors during compilation, the compiler writes the messages to stderr. At the end of the messages, a summary message is displayed that gives the total number of each type of message:

filename: n warnings, n errors

n indicates the number of warnings or errors detected.

Note

Remarks are not displayed by default. To display remarks, use the --remarks compiler option. No summary message is displayed if only remark messages are generated.

Response to signals

The signals SIGINT (caused by a user interrupt, like ^C) and SIGTERM (caused by a UNIX kill command) are trapped by the compiler and cause abnormal termination.

Exit status

On completion, the compiler returns a value greater than zero if an error is detected. See Severity of diagnostic messages for details on how the compiler handles the different levels of diagnostic messages.

Data flow warnings

The compiler issues warnings about the use of uninitialized variables based on its dataflow analysis. The compiler does more of this analysis at higher optimization and so more warnings might be produced at higher optimization levels. For example:


int f() { int i; return i++; }

produces the following warning at -O2:


Warning: C2874W: i may be used before being set

The check is pessimistic and sometimes reports an anomaly where there is none, for example, when building the Dhrystone example you might see:


"dhry_1.c", line 337: Warning: C2874W: Enum_Loc may be used before being set "dhry_1.c", line 89: Warning: C2874W: Int_2_Loc may be used before being set

Note

Data flow warnings are issued by default. In previous versions of the compiler, data flow warnings were issued only if the -fa option was specified.

Copyright © 2005 ARM Limited. All rights reserved.ARM DUI 0282B
Non-Confidential