This revision was automatically updated to reflect the committed changes. Closed by commit rG99fd06622784: [clang][Sema] Don't try to initialize implicit variable of invalid anonymous… (authored by TaWeiTu).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D98548/new/ https://reviews.llvm.org/D98548 Files: clang/lib/Sema/SemaDecl.cpp clang/test/SemaCXX/PR49534.cpp Index: clang/test/SemaCXX/PR49534.cpp =================================================================== --- /dev/null +++ clang/test/SemaCXX/PR49534.cpp @@ -0,0 +1,6 @@ +// RUN: %clang_cc1 -x c++ -fsyntax-only %s -verify + +static union { // expected-warning {{declaration does not declare anything}} + virtual int a(); // expected-error {{unions cannot have virtual functions}} \ + // expected-error {{functions cannot be declared in an anonymous union}} +}; Index: clang/lib/Sema/SemaDecl.cpp =================================================================== --- clang/lib/Sema/SemaDecl.cpp +++ clang/lib/Sema/SemaDecl.cpp @@ -5211,7 +5211,8 @@ // trivial in almost all cases, except if a union member has an in-class // initializer: // union { int n = 0; }; - ActOnUninitializedDecl(Anon); + if (!Invalid) + ActOnUninitializedDecl(Anon); } Anon->setImplicit();
Index: clang/test/SemaCXX/PR49534.cpp =================================================================== --- /dev/null +++ clang/test/SemaCXX/PR49534.cpp @@ -0,0 +1,6 @@ +// RUN: %clang_cc1 -x c++ -fsyntax-only %s -verify + +static union { // expected-warning {{declaration does not declare anything}} + virtual int a(); // expected-error {{unions cannot have virtual functions}} \ + // expected-error {{functions cannot be declared in an anonymous union}} +}; Index: clang/lib/Sema/SemaDecl.cpp =================================================================== --- clang/lib/Sema/SemaDecl.cpp +++ clang/lib/Sema/SemaDecl.cpp @@ -5211,7 +5211,8 @@ // trivial in almost all cases, except if a union member has an in-class // initializer: // union { int n = 0; }; - ActOnUninitializedDecl(Anon); + if (!Invalid) + ActOnUninitializedDecl(Anon); } Anon->setImplicit();
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits