Files
codeql/cpp/ql/test/query-tests/Documentation/CommentedOutCode/test2.cpp
Owen Mansel-Chan f54debd65a C++
2026-06-10 22:57:08 +02:00

122 lines
1.6 KiB
C++

/*
* This sentence contains a semicolon;
* however, this doesn't make it code.
*/
// This sentence contains a semicolon;
// however, this doesn't make it code.
/* Mention a ';' */
/* Mention a '{' */
/* JSON example: {"foo":"bar"} */
/* JSON example in backticks: `{"foo":"bar"}` */
/* JSON example in quotes: '{"foo":"bar"}' */
/*
* Code example: `return 0;`.
*/
// Code example:
//
// return 0;
// Code example:
//
// ```
// return 0;
// ```
// { 1, 2, 3, 4 }
// Example: { 1, 2, 3, 4 }
// int myFunction() { return myValue; } // $ Alert
// int myFunction() const { return myValue; } // $ Alert
// int myFunction() const noexcept { return myValue; } // $ Alert
// #define MYMACRO // $ Alert
// #include "include.h" // $ Alert
/*
#ifdef
void myFunction();
#endif
*/ // $ Alert
// define some constants
// don't #include anything here
// #hashtag
// #if(defined(MYMACRO)) // $ Alert
// #iffy
// #pragma once // $ Alert
// # pragma once // $ Alert
/*#error"myerror"*/ // $ Alert
#ifdef MYMACRO
// ...
#endif // #ifdef MYMACRO
#if !defined(MYMACRO)
// ...
#else // #if !defined(MYMACRO)
// ...
#endif // #else #if !defined(MYMACRO)
#ifdef MYMACRO
// ...
#endif // #ifdef MYMACRO (comment)
/*
#ifdef MYMACRO
// ...
#endif // #ifdef MYMACRO
*/ // $ Alert
#ifdef MYMACRO1
#ifdef MYMACRO2
// ...
// comment at end of block
#endif // #ifdef MYMACRO2
#endif // #ifdef MYMACRO1
#include "config.h" // #include "config2.h" // $ Alert
#ifdef MYMACRO
// ...
#endif /* #ifdef MYMACRO */
#error "error" /* #ifdef MYMACRO */ // $ Alert
// commented_out_code(); // $ Alert
#if 0
// commented_out_code(); // $ Alert
#endif