Skip to content
This repository was archived by the owner on Apr 23, 2020. It is now read-only.

Commit e531001

Browse files
committed
PR12688: ParseCXXClassMemberDeclaration's sometimes-null ThisDecl takes another
victim. Don't crash if we have a delay-parsed exception specification for a class member which is invalid in a way which precludes building a FunctionDecl. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155788 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent a2e76f5 commit e531001

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

lib/Parse/ParseDeclCXX.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2065,7 +2065,7 @@ void Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS,
20652065
DeclsInGroup.push_back(ThisDecl);
20662066
}
20672067

2068-
if (DeclaratorInfo.isFunctionDeclarator() &&
2068+
if (ThisDecl && DeclaratorInfo.isFunctionDeclarator() &&
20692069
DeclaratorInfo.getDeclSpec().getStorageClassSpec()
20702070
!= DeclSpec::SCS_typedef) {
20712071
HandleMemberFunctionDeclDelays(DeclaratorInfo, ThisDecl);

test/CXX/class/class.mem/p2.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,16 @@ namespace PR12629 {
7373
static_assert(!noexcept(S().h()), "");
7474
static_assert(noexcept(S::i()), "");
7575
}
76+
77+
namespace PR12688 {
78+
struct S {
79+
// FIXME: Producing one error saying this can't have the same name
80+
// as the class because it's not a constructor, then producing
81+
// another error saying this can't have a return type because
82+
// it is a constructor, is redundant and inconsistent.
83+
nonsense S() throw (more_nonsense); // \
84+
// expected-error {{'nonsense'}} \
85+
// expected-error {{has the same name as its class}} \
86+
// expected-error {{constructor cannot have a return type}}
87+
};
88+
}

0 commit comments

Comments
 (0)