On Tue, Feb 24, 2015 at 5:38 PM, Davide Italiano <[email protected]>
wrote:

> Hi Richard.
>
> Building the following testcase
>  % cat blah.cpp
> struct {
>   struct A <struct A {
>
> results in a crash in Sema, namely:
>
> % clang blah.cpp -o blah
> [...]
> Invalid access specifier!
> UNREACHABLE executed at
>
> /usr/src/lib/clang/libclangast/../../../contrib/llvm/tools/clang/lib/AST/DeclCXX.cpp:2145!
>
> I would like to propose the following patch to fix that up.
> Rather than crashing, if we don't have informations about the previous
> declaration access specifier, we can just throw an error.
>
> diff --git a/lib/Sema/SemaAccess.cpp b/lib/Sema/SemaAccess.cpp
> index 37240c2..7433c8c 100644
> --- a/lib/Sema/SemaAccess.cpp
> +++ b/lib/Sema/SemaAccess.cpp
> @@ -45,6 +45,11 @@ bool Sema::SetMemberAccessSpecifier(NamedDecl
> *MemberDecl,
>      return false;
>    }
>
> +  // If a previous member declaration exists, and the access specifier
> +  // is not valid, just error out.
> +  if (PrevMemberDecl->getAccess() == AS_none)
>

(As discussed on IRC) Please assert that the previous declaration is marked
invalid here, and mark the new member declaration as invalid in this case.

+    return true;
> +
>    // C++ [class.access.spec]p3: When a member is redeclared its access
>    // specifier must be same as its initial declaration.
>    if (LexicalAS != AS_none && LexicalAS != PrevMemberDecl->getAccess()) {
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to