Skip to content

A16-0-1: Fix handling of #else and #elif in valid preprocessor conditionals #386

Closed
@lcartey

Description

@lcartey

Affected rules

  • A16-0-1

Description

We erroneously identify otherwise acceptable conditionals with #else or #elif preprocessor directives as invalid, as the #else and #elif are not considered de facto valid.

This should be addressed by:

  • Always considering #else acceptable, and relying on reporting any issues in the #..if directive.
  • Considering #elif an acceptable directive within a preprocessor conditional, but still considering the #elif on its own merits.

Example

#ifdef MACRO_ENABLED
#include "test1.h"
#else
#include "test2.h"
#endif

Metadata

Metadata

Assignees

Labels

Difficulty-LowA false positive or false negative report which is expected to take <1 day effort to addressImpact-Mediumfalse positive/false negativeAn issue related to observed false positives or false negatives.user-reportIssue reported by an end user of CodeQL Coding Standards

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions