Commit 0372f89d authored by Oliver Kellogg's avatar Oliver Kellogg
Browse files

Fix for "C++ importer does not recognize 'noexcept' keyword" :

lib/cppparser/keywords.h
- Align INSERT calls as table. Add INSERT("noexcept", Token_noexcept).

lib/cppparser/lexer.h
- In enum Type add Token_noexcept.

lib/cppparser/parser.cpp
- In functions skipUntilDeclaration, skipUntilStatement while-loop
  switch add case Token_noexcept.
- In function parseExceptionSpecification handle the case
  (m_lexer->lookAhead(0) == Token_noexcept).

test/import/cxx/const-methods.h
- Rename file to const-noexcept-methods.h.

test/import/cxx/const-noexcept-methods.h
- Rename class to ConstNoexceptMethodClass.
- Add NoexceptMethod with trailing noexcept.
- Add ConstNoexceptMethod with const noexcept and implementation.

BUG: 442134
CCBUG: 338649
parent 0457a2eb
......@@ -4,94 +4,95 @@
//
#define INSERT(x, y) keywords.insert(x, y)
// KDE Keywords
INSERT("K_DCOP", Token_K_DCOP);
INSERT("k_dcop", Token_k_dcop);
INSERT("k_dcop_signals", Token_k_dcop_signals);
INSERT("K_DCOP", Token_K_DCOP);
INSERT("k_dcop", Token_k_dcop);
INSERT("k_dcop_signals", Token_k_dcop_signals);
// Qt Keywords
INSERT("Q_OBJECT", Token_Q_OBJECT);
INSERT("signals", Token_signals);
INSERT("Q_SLOTS", Token_slots);
INSERT("slots", Token_slots);
INSERT("emit", Token_emit);
INSERT("foreach", Token_foreach);
INSERT("Q_OBJECT", Token_Q_OBJECT);
INSERT("signals", Token_signals);
INSERT("Q_SLOTS", Token_slots);
INSERT("slots", Token_slots);
INSERT("emit", Token_emit);
INSERT("foreach", Token_foreach);
// C++ Keywords
INSERT("__int64", Token_int);
INSERT("__asm__", Token_asm);
INSERT("and", Token_and);
INSERT("and_eq", Token_and_eq);
INSERT("asm", Token_asm);
INSERT("auto", Token_auto);
INSERT("bitand", Token_bitand);
INSERT("bitor", Token_bitor);
INSERT("bool", Token_bool);
INSERT("break", Token_break);
INSERT("case", Token_case);
INSERT("catch", Token_catch);
INSERT("char", Token_char);
INSERT("class", Token_class);
INSERT("compl", Token_compl);
INSERT("const", Token_const);
INSERT("constexpr", Token_const_expr);
INSERT("const_cast", Token_const_cast);
INSERT("continue", Token_continue);
INSERT("default", Token_default);
INSERT("delete", Token_delete);
INSERT("do", Token_do);
INSERT("double", Token_double);
INSERT("dynamic_cast", Token_dynamic_cast);
INSERT("else", Token_else);
INSERT("enum", Token_enum);
INSERT("explicit", Token_explicit);
INSERT("export", Token_export);
INSERT("extern", Token_extern);
INSERT("float", Token_float);
INSERT("for", Token_for);
INSERT("friend", Token_friend);
INSERT("goto", Token_goto);
INSERT("if", Token_if);
INSERT("inline", Token_inline);
INSERT("int", Token_int);
INSERT("long", Token_long);
INSERT("mutable", Token_mutable);
INSERT("namespace", Token_namespace);
INSERT("new", Token_new);
INSERT("not", Token_not);
INSERT("not_eq", Token_not_eq);
INSERT("operator", Token_operator);
INSERT("or", Token_or);
INSERT("or_eq", Token_or_eq);
INSERT("override", Token_override);
INSERT("private", Token_private);
INSERT("protected", Token_protected);
INSERT("public", Token_public);
INSERT("register", Token_register);
INSERT("__int64", Token_int);
INSERT("__asm__", Token_asm);
INSERT("and", Token_and);
INSERT("and_eq", Token_and_eq);
INSERT("asm", Token_asm);
INSERT("auto", Token_auto);
INSERT("bitand", Token_bitand);
INSERT("bitor", Token_bitor);
INSERT("bool", Token_bool);
INSERT("break", Token_break);
INSERT("case", Token_case);
INSERT("catch", Token_catch);
INSERT("char", Token_char);
INSERT("class", Token_class);
INSERT("compl", Token_compl);
INSERT("const", Token_const);
INSERT("constexpr", Token_const_expr);
INSERT("const_cast", Token_const_cast);
INSERT("continue", Token_continue);
INSERT("default", Token_default);
INSERT("delete", Token_delete);
INSERT("do", Token_do);
INSERT("double", Token_double);
INSERT("dynamic_cast", Token_dynamic_cast);
INSERT("else", Token_else);
INSERT("enum", Token_enum);
INSERT("explicit", Token_explicit);
INSERT("export", Token_export);
INSERT("extern", Token_extern);
INSERT("float", Token_float);
INSERT("for", Token_for);
INSERT("friend", Token_friend);
INSERT("goto", Token_goto);
INSERT("if", Token_if);
INSERT("inline", Token_inline);
INSERT("int", Token_int);
INSERT("long", Token_long);
INSERT("mutable", Token_mutable);
INSERT("namespace", Token_namespace);
INSERT("new", Token_new);
INSERT("noexcept", Token_noexcept);
INSERT("not", Token_not);
INSERT("not_eq", Token_not_eq);
INSERT("operator", Token_operator);
INSERT("or", Token_or);
INSERT("or_eq", Token_or_eq);
INSERT("override", Token_override);
INSERT("private", Token_private);
INSERT("protected", Token_protected);
INSERT("public", Token_public);
INSERT("register", Token_register);
INSERT("reinterpret_cast", Token_reinterpret_cast);
INSERT("return", Token_return);
INSERT("short", Token_short);
INSERT("signed", Token_signed);
INSERT("sizeof", Token_sizeof);
INSERT("static", Token_static);
INSERT("static_cast", Token_static_cast);
INSERT("struct", Token_struct);
INSERT("switch", Token_switch);
INSERT("template", Token_template);
INSERT("this", Token_this);
INSERT("throw", Token_throw);
INSERT("try", Token_try);
INSERT("typedef", Token_typedef);
INSERT("typeid", Token_typeid);
INSERT("typename", Token_typename);
INSERT("union", Token_union);
INSERT("unsigned", Token_unsigned);
INSERT("using", Token_using);
INSERT("virtual", Token_virtual);
INSERT("void", Token_void);
INSERT("volatile", Token_volatile);
INSERT("while", Token_while);
INSERT("xor", Token_xor);
INSERT("xor_eq", Token_xor_eq);
INSERT("return", Token_return);
INSERT("short", Token_short);
INSERT("signed", Token_signed);
INSERT("sizeof", Token_sizeof);
INSERT("static", Token_static);
INSERT("static_cast", Token_static_cast);
INSERT("struct", Token_struct);
INSERT("switch", Token_switch);
INSERT("template", Token_template);
INSERT("this", Token_this);
INSERT("throw", Token_throw);
INSERT("try", Token_try);
INSERT("typedef", Token_typedef);
INSERT("typeid", Token_typeid);
INSERT("typename", Token_typename);
INSERT("union", Token_union);
INSERT("unsigned", Token_unsigned);
INSERT("using", Token_using);
INSERT("virtual", Token_virtual);
INSERT("void", Token_void);
INSERT("volatile", Token_volatile);
INSERT("while", Token_while);
INSERT("xor", Token_xor);
INSERT("xor_eq", Token_xor_eq);
//
// End of file
......
......@@ -95,6 +95,7 @@ enum Type {
Token_mutable,
Token_namespace,
Token_new,
Token_noexcept,
Token_not,
Token_not_eq,
Token_operator,
......
......@@ -203,9 +203,10 @@ bool Parser::skipUntilDeclaration()
case Token_export:
case Token_const: // cv
case Token_const_expr: // cv
case Token_noexcept:
case Token_const_expr: // cv
case Token_volatile: // cv
case Token_mutable: // cv
case Token_mutable: // cv
case Token_public:
case Token_protected:
......@@ -235,6 +236,7 @@ bool Parser::skipUntilStatement()
case Token_const_expr:
case Token_volatile:
case Token_mutable:
case Token_noexcept:
case Token_identifier:
case Token_case:
case Token_default:
......@@ -2200,6 +2202,17 @@ bool Parser::parseExceptionSpecification(GroupAST::Node& node)
{
PARSER_DEBUG_METHOD;
if (m_lexer->lookAhead(0) == Token_noexcept) {
GroupAST::Node ast = CreateNode<GroupAST>();
int start = m_lexer->index();
nextToken();
AST::Node word = CreateNode<AST>();
UPDATE_POS(word, start, m_lexer->index());
ast->addNode(word);
node = std::move(ast);
return true;
}
if (m_lexer->lookAhead(0) != Token_throw) {
return false;
}
......
class ConstMethodClass {
bool ConstMethod(QString &param) const;
};
class ConstNoexceptMethodClass {
bool ConstMethod(QString &param) const;
bool NoexceptMethod(QString &param) noexcept;
bool ConstNoexceptMethod(QString &param) const noexcept { return true }
};
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment