Describe the bug
After upgrading our compiler to gcc 11 I started to get parse error for some of my C++ code.
After some digging I traced the parse error to the <bits/c++config.h> system header.
With some more digging and simplification I reduced the problematic code to the one in the next part.
To Reproduce
Steps to reproduce the behavior:
- Create a source file with this content:
#define DUMMY __has_include(<apa/bepa.h>)
#if DUMMY
#endif
- Run the scanner.
Both the #define and the #if are necessary to reproduce the bug.
Expected behavior
No "unable to lex" parse error.
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
- OS: Fedora 35 Linux
- SonarQube version: 8.9.8
- cxx plugin version: 2.0.7.3119
- sonar-scanner version: 4.7.0.2747
- gcc version: 11.3.1
Additional context
Patch for updating an existing test with this special case:
diff --git a/cxx-squid/src/test/resources/parser/own/C++17/has-include.cc b/cxx-squid/src/test/resources/parser/own/C++17/has-include.cc
index 3b906c91..5f7e35af 100644
--- a/cxx-squid/src/test/resources/parser/own/C++17/has-include.cc
+++ b/cxx-squid/src/test/resources/parser/own/C++17/has-include.cc
@@ -1,8 +1,12 @@
+#define EXISTS __has_include("i25/has_include.h")
+
#ifdef __has_include // Check if __has_include is present
# if __has_include("i1/has_include.h") // Check for a standard library
# include "i1/has_include1"
# elif __has_include("i2/has_include.h") // Check for an experimental version
# include "i2/has_include"
+# elif EXISTS
+# include "i25/has_include.h"
# elif __has_include("i3/has_include.h") // Try with an external library
# include "i3/has_include.h"
# else // Not found at all
Describe the bug
After upgrading our compiler to gcc 11 I started to get parse error for some of my C++ code.
After some digging I traced the parse error to the
<bits/c++config.h>system header.With some more digging and simplification I reduced the problematic code to the one in the next part.
To Reproduce
Steps to reproduce the behavior:
Both the
#defineand the#ifare necessary to reproduce the bug.Expected behavior
No "unable to lex" parse error.
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Additional context
Patch for updating an existing test with this special case: