This commit is contained in:
parent
034140e7e1
commit
7cedf3e0e5
|
@ -6340,6 +6340,7 @@ static const Token * parsedecl(const Token *type, ValueType * const valuetype, V
|
||||||
valuetype->type = vt2->type;
|
valuetype->type = vt2->type;
|
||||||
valuetype->constness += vt2->constness;
|
valuetype->constness += vt2->constness;
|
||||||
valuetype->pointer += vt2->pointer;
|
valuetype->pointer += vt2->pointer;
|
||||||
|
valuetype->reference = vt2->reference;
|
||||||
type = type->linkAt(1)->next();
|
type = type->linkAt(1)->next();
|
||||||
continue;
|
continue;
|
||||||
} else if (type->isSigned())
|
} else if (type->isSigned())
|
||||||
|
|
|
@ -124,6 +124,7 @@ private:
|
||||||
TEST_CASE(returnReference22);
|
TEST_CASE(returnReference22);
|
||||||
TEST_CASE(returnReference23);
|
TEST_CASE(returnReference23);
|
||||||
TEST_CASE(returnReference24); // #10098
|
TEST_CASE(returnReference24); // #10098
|
||||||
|
TEST_CASE(returnReference25); // #10983
|
||||||
TEST_CASE(returnReferenceFunction);
|
TEST_CASE(returnReferenceFunction);
|
||||||
TEST_CASE(returnReferenceContainer);
|
TEST_CASE(returnReferenceContainer);
|
||||||
TEST_CASE(returnReferenceLiteral);
|
TEST_CASE(returnReferenceLiteral);
|
||||||
|
@ -1552,6 +1553,18 @@ private:
|
||||||
ASSERT_EQUALS("[test.cpp:5]: (error) Reference to temporary returned.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:5]: (error) Reference to temporary returned.\n", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void returnReference25()
|
||||||
|
{
|
||||||
|
check("int& f();\n" // #10983
|
||||||
|
" auto g() -> decltype(f()) {\n"
|
||||||
|
" return f();\n"
|
||||||
|
"}\n"
|
||||||
|
"int& h() {\n"
|
||||||
|
" return g();\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
}
|
||||||
|
|
||||||
void returnReferenceFunction() {
|
void returnReferenceFunction() {
|
||||||
check("int& f(int& a) {\n"
|
check("int& f(int& a) {\n"
|
||||||
" return a;\n"
|
" return a;\n"
|
||||||
|
|
Loading…
Reference in New Issue