Cpp.Norm Class
Namespace: Cpp
Contains predicates that check if a keyword is a C or C++ keyword
Since R2026a
Description
The PQL class Norm allows you to check if a Polyspace Query Language
(PQL) string object contains a C or C++ keyword. This card does not represent a syntax node
and does not define a PQL type.
Predicates
This class defines predicates for C and C++ keyword. This table summarizes the predicates that check if a string is a C++ keyword.
| Predicates for C++ keywords | Description |
|---|---|
isCpp98Keyword(Lang.String word)
| Checks if word matches one of these C++89 keywords:
asm, bool,
catch, class,
const_cast, delete,
dynamic_cast, explicit,
export, false,
friend, inline,
mutable, namespace,
new, operator,
private, protected,
public, reinterpret_cast,
static_cast, template,
this, throw,
true, try,
typeid, typename,
using, virtual, or
wchar_t. |
isCpp11Extension(Lang.String word)
| Checks if the string word matches the keywords
introduced in C++11: alignas, alignof,
constexpr, decltype,
noexcept, nullptr,
static_assert,
thread_local. |
isCpp11Keyword(Lang.String word)
| Checks if word is a keyword in C++11. The list of
keywords in C++11 is a union of C++89 keywords and the new keywords
introduced in C++11. |
isCpp14Keyword(Lang.String word)
| Checks if word is a keyword in C++14. The list of
keywords in C++14 is a union of C++89 keywords and the new keywords
introduced in C++11. |
isCpp17Extension(Lang.String word)
| Checks if the string word matches the keywords
introduced in C++17: concept. |
isCpp17Keyword(Lang.String word)
| Checks if word is a keyword in C++17. The list of
keywords in C++14 is a union of C++14 keywords and the new keywords
introduced in C++17. |
isCpp20Extension(Lang.String word) | Checks if word is a keywords introduced in C++20:
consteval, constinit,
co_await, co_return,
co_yield, orrequires. |
isCpp20Keyword(Lang.String word) | Checks if word is a keyword in C++20. The list of
keywords in C++20 is a union of C++17 keywords and the new keywords
introduced in C++20. |
isCpp23Extension(Lang.String word) | Checks if word is a keywords introduced in C++23:
abstract, concepts,
explicit, import,
module, reflexpr. |
isCpp23Keyword(Lang.String word) | Checks if word is a keyword in C++23. The list of
keywords in C++23 is a union of C++20 keywords and the new keywords
introduced in C++23. |
This table summarizes the predicates that check if a string is a C keyword.
| Predicates for C++ keywords | Description |
|---|---|
isC89Keyword(Lang.String word)
| Checks if the string word one of these C89 keywords:
auto, break,
case, char,
const, continue,
default, do,
double, else,
enum, extern,
float, for,
goto, if, int,
long, register,
return, short,
signed, sizeof,
static, struct,
switch, typedef,
union, unsigned,
void, volatile, or
while. |
isC90Keyword(Lang.String word)
| Checks if the string is a C91 keyword. C90 and C89 has the same list of keywords. |
isC99Extension(Lang.String word)
| Checks if the string word matches the keywords
introduced in C99:
inline, restrict, _Bool, _Complex, _Imaginary
. |
isC99Keyword(Lang.String word)
| Checks if word is a keyword in C99. The list of
keywords in C99 is a union of C90 keywords and the new keywords introduced
in C99. |
isC11Extension(Lang.String word)
| Checks if the string word matches the keywords
introduced in C11: _Alignas, _Alignof,
_Atomic, _Generic,
_Noreturn, _Static_assert, or
_Thread_local. |
isC11Keyword(Lang.String word)
| Checks if word is a keyword in C11. The list of
keywords in C11 is a union of C99 keywords and the new keywords introduced
in C11. |
isC17Keyword(Lang.String word) | Checks if word is a keyword in C17. The list of
keywords in C17 the same as the keywords in C11. |
isC23Extension(Lang.String word) | Checks if the string word matches the keywords
introduced in C23: alignas, alignof,
constexpr, nullptr,
static_assert, typeof, or
thread_local . |
isC23Keyword(Lang.String word) | Checks if word is a keyword in C23. The list of
keywords in C23 is a union of C11 keywords and the new keywords introduced
in C23. |
Examples
Check If C++ Keywords are Redefined
Consider this C/C++ code that redefines keywords:
#define class my_class // Preprocessor replaces 'class' tokens with 'my_class' #define int my_int // Preprocessor replaces 'int' tokens with 'my_int' #define ADD(a, b) ((a) + (b))
To detect preprocessor definitions that redefine C++23 keywords, define this defect:
defect mydefect =
when
Cpp.PreprocDef.is(&preproc)
and preproc.name(&name)
and name.nodeText(&str)
and Cpp.Norm.isCpp23Keyword(str)
raise "C++23 keyword redefined in macro: \"{str}\""
on nameclass and int.Version History
Introduced in R2026a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)