#5702 crash: clang: test/Parser/cxx0x-member-initializers.cpp (bailout withn an internal error)

This commit is contained in:
Alexander Mai 2014-04-21 21:44:17 +02:00
parent 6f3e3f5e2e
commit 623e5db0b2
2 changed files with 11 additions and 2 deletions

View File

@ -432,6 +432,8 @@ bool CheckClass::isBaseClassFunc(const Token *tok, const Scope *scope)
void CheckClass::initializeVarList(const Function &func, std::list<const Function *> &callstack, const Scope *scope, std::vector<Usage> &usage)
{
if (!func.functionScope)
throw InternalError(0, "Internal Error: Invalid syntax"); // #5702
bool initList = func.isConstructor();
const Token *ftok = func.arg->link()->next();
int level = 0;

View File

@ -183,6 +183,7 @@ private:
TEST_CASE(pureVirtualFunctionCallPrevented);
TEST_CASE(duplInheritedMembers);
TEST_CASE(invalidInitializerList);
}
void checkDuplInheritedMembers(const char code[]) {
@ -1970,12 +1971,12 @@ private:
ASSERT_EQUALS("[test.cpp:9]: (error) Class 'AA<double>' which is inherited by class 'B' does not have a virtual destructor.\n", errout.str());
}
void checkNoConstructor(const char code[]) {
void checkNoConstructor(const char code[], const char* level="style") {
// Clear the error log
errout.str("");
Settings settings;
settings.addEnabled("style");
settings.addEnabled(level);
// Tokenize..
Tokenizer tokenizer(&settings, this);
@ -5974,6 +5975,12 @@ private:
ASSERT_EQUALS("", errout.str());
}
void invalidInitializerList() {
ASSERT_THROW(checkNoConstructor("struct R1 {\n"
" int a;\n"
" R1 () : a { }\n"
"};\n", "warning"), InternalError);
}
};
REGISTER_TEST(TestClass)