You copied the Doc URL to your clipboard.

Controlling diagnostic messages

Arm® Compiler provides diagnostic messages in the form of warnings and errors. You can use options to suppress these messages or enable them as either warnings or errors.

Arm Compiler lists all the warnings and errors it encounters during the compiling and linking process. However, if you specify multiple source files, Arm Compiler only reports diagnostic information for the first source file that it encounters an error in.

Message format for armclang

armclang produces messages in the following format:

file:line:col: type: message
file

The filename that contains the error or warning.

line

The line number that contains the error or warning.

col

The column number that generated the message.

type

The type of the message, for example error or warning.

message

The message text. This text might end with a diagnostic flag of the form -Wflag, for example -Wvla-extension, to identify the error or warning. Only the messages that you can suppress have an associated flag. Errors that you cannot suppress do not have an associated flag.

An example warning diagnostic message is:

file.c:8:7: warning: variable length arrays are a C99 feature [-Wvla-extension]
 int i[n];
      ^

This warning message tells you:

  • The file that contains the problem is called file.c.
  • The problem is on line 8 of file.c, and starts at character 7.
  • The warning is about the use of a variable length array i[n].
  • The flag to identify, enable, or disable this diagnostic message is vla-extension.

The following are common options that control diagnostic output from armclang.

Table 2-12 Common diagnostic options

Option Description
-Werror Turn all warnings into errors.
-Werror=foo Turn warning flag foo into an error.
-Wno-error=foo Leave warning flag foo as a warning even if -Werror is specified.
-Wfoo Enable warning flag foo.
-Wno-foo Suppress warning flag foo.
-w Suppress all warnings. Note that this option is a lowercase w.
-Weverything Enable all warnings.
-Wpedantic Generate warnings if code violates strict ISO C and ISO C++.
-pedantic Generate warnings if code violates strict ISO C and ISO C++.
-pedantic-errors Generate errors if code violates strict ISO C and ISO C++.

See Controlling Errors and Warnings in the Clang Compiler User's Manual for full details about controlling diagnostics with armclang.

Examples of controlling diagnostic messages with armclang

Copy the following code example to file.c and compile it with Arm Compiler to see example diagnostic messages.

#include <stdlib.h>
#include <stdio.h>

void function (int x) {
    int i;
    int y=i+x;

    printf("Result of %d plus %d is %d\n", i, x); /* Missing an input argument for the third %d */
    call(); /* This function has not been declared and is therefore an implicit declaration */

    return;
}

Compile file.c using:

armclang --target=aarch64-arm-none-eabi -march=armv8 -c file.c

By default, armclang checks the format of printf() statements to ensure that the number of % format specifiers matches the number of data arguments. Therefore armclang generates this diagnostic message:

file.c:9:36: warning: more '%' conversions than data arguments [-Wformat]
				printf("Result of %d plus %d is %d\n", i, x);
                                                     ^

By default, armclang compiles for the gnu11 standard for .c files. This language standard does not allow implicit function declarations. Therefore armclang generates this diagnostic message:

file.c:11:3: warning: implicit declaration of function 'call' is invalid C99 [-Wimplicit-function-declaration]
    call();
    ^

To suppress all warnings, use -w:

armclang --target=aarch64-arm-none-eabi -march=armv8-a -c file.c -w

To suppress only the -Wformat warning, use -Wno-format:

armclang --target=aarch64-arm-none-eabi -march=armv8-a -c file.c -Wno-format

To enable the -Wformat message as an error, use -Werror=format:

armclang --target=aarch64-arm-none-eabi -march=armv8-a -c file.c -Werror=format

Some diagnostic messages are suppressed by default. To see all diagnostic messages, use -Weverything:

armclang --target=aarch64-arm-none-eabi -march=armv8-a -c file.c -Weverything

Pragmas for controlling diagnostics with armclang

Pragmas within your source code can control the output of diagnostics from the armclang compiler.

See Controlling Errors and Warnings in the Clang Compiler User's Manual for full details about controlling diagnostics with armclang.

The following are some of the common options that control diagnostics:

#pragma clang diagnostic ignored "-Wname"

Ignores the diagnostic message specified by name.

#pragma clang diagnostic warning "-Wname"

Sets the diagnostic message specified by name to warning severity.

#pragma clang diagnostic error "-Wname"

Sets the diagnostic message specified by name to error severity.

#pragma clang diagnostic fatal "-Wname"

Sets the diagnostic message specified by name to fatal error severity.

#pragma clang diagnostic push

Saves the diagnostic state so that it can be restored.

#pragma clang diagnostic pop

Restores the last saved diagnostic state.

The compiler provides appropriate diagnostic names in the diagnostic output.

Note

Alternatively, you can use the command-line option, -Wname, to suppress or change the severity of messages, but the change applies for the entire compilation.

Example of using pragmas to selectively override a command-line option

foo.c:
#if foo
#endif foo /* no warning when compiling with -Wextra-tokens */

#pragma clang diagnostic push
#pragma clang diagnostic warning "-Wextra-tokens"

#if foo
#endif foo /* warning: extra tokens at end of #endif directive */

#pragma clang diagnostic pop

If you build this example with:

armclang --target=arm-arm-none-eabi -march=armv7-a -c foo.c -o foo.o -Wno-extra-tokens

The compiler only generates a warning for the second instance of #endif foo:

foo.c:8:8: warning: extra tokens at end of #endif directive [-Wextra-tokens]
#endif foo /* warning: extra tokens at end of #endif directive */
       ^
       //
1 warning generated.

Message format for other tools

The other tools in the toolchain (such as armasm and armlink) produce messages in the following format:

type: prefix id suffix: message_text
type

One of the following types:

Internal fault

Internal faults indicate an internal problem with the tool. Contact your supplier with feedback.

Error

Errors indicate problems that cause the tool to stop.

Warning

Warnings indicate unusual conditions that might indicate a problem, but the tool continues.

Remark

Remarks indicate common, but sometimes unconventional, tool usage. These diagnostics are not displayed by default. The tool continues.

prefix

The tool that generated the message, one of:

  • A - armasm
  • L - armlink or armar
  • Q - fromelf
id

A unique numeric message identifier.

suffix

The type of message, one of:

  • E - Error
  • W - Warning
  • R - Remark
message_text

The text of the message.

For example, the following armlink error message:

Error: L6449E: While processing /home/scratch/a.out: I/O error writing file '/home/scratch/a.out': Permission denied

All the diagnostic messages that are in this format, and any additional information, are in the Arm® Compiler Errors and Warnings Reference Guide.

Options for controlling diagnostics with the other tools

Several different options control diagnostics with the armasm, armlink, armar, and fromelf tools:

--brief_diagnostics

armasm only. Uses a shorter form of the diagnostic output. 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.

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

Sets the specified diagnostic messages to Error severity. Use --diag_error=warning to treat all warnings as errors.

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

Sets the specified diagnostic messages to Remark severity.

--diag_style=arm|ide|gnu

Specifies the display style for diagnostic messages.

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

Suppresses the specified diagnostic messages. Use --diag_suppress=error to suppress all errors that can be downgraded, or --diag_suppress=warning to suppress all warnings.

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

Sets the specified diagnostic messages to Warning severity. Use --diag_warning=error to set all errors that can be downgraded to warnings.

--errors=filename

Redirects the output of diagnostic messages to the specified file.

--remarks

armlink only. Enables the display of remark messages (including any messages redesignated to remark severity using --diag_remark).

tag is the four-digit diagnostic number, nnnn, with the tool letter prefix, but without the letter suffix indicating the severity. A full list of tags with the associated suffixes is in the Arm® Compiler Errors and Warnings Reference Guide.

For example, to downgrade a warning message to Remark severity:

$ armasm test.s --cpu=8-A.32
"test.s", line 55: Warning: A1313W: Missing END directive at end of file
0 Errors, 1 Warning

$ armasm test.s --cpu=8-A.32 --diag_remark=A1313
"test.s", line 55: Missing END directive at end of file
Was this page helpful? Yes No