![]() |
![]() |
1401 | ![]() |
||||
![]() | |||||||
| Arithmetic type - Enum types | REFERENCE - ISO:C90-6.5.2.2 Enumeration Specifiers | ||||||
An enum constant is being passed as a function argument. However, the corresponding parameter in the function definition is of a different enum type. This is permitted in the C language but is it really intended ? If the value of the enum constant does not coincide with one of the enumeration constants in the other enum type, an additional message will be generated.
/*PRQA S 1277,2006,2017,2201,2203,3198,3227,3408,3447,3448,3602 ++*/
typedef enum tree
{
fir = 0x0001,
cedar = 0x0002,
maple = 0x0004,
pine = 0x0008 } TREE;
enum color
{
red = 0x0001,
white = 0x0002,
black = 0x0003,
yellow= 0x0004,
blue = 0x0005,
violet= 0x0020 };
extern void func1(TREE trp);
extern TREE tra;
extern TREE foo(int m)
{
if (m < 0)
{
tra = white; /* Message 1402 */
func1(white); /* Message 1401 */
return(white); /* Message 1403 */
}
else if (m > 0)
{
tra = violet; /* Message 1402 and 1317 */
func1(violet); /* Message 1401 and 1317 */
return(violet); /* Message 1403 and 1317 */
}
else
{
tra = black; /* Message 1402 and 1461 */
func1(black); /* Message 1401 and 1461 */
return (black); /* Message 1403 and 1461 */
}
}
See also:
![]() | ||
| QA·C Source Code Analyser 8.1.2
© 2013 Programming Research. www.programmingresearch.com | Personality Groups | Glossary | Message Index | Contents |