================
@@ -751,20 +753,21 @@ void Parser::ParseLexedAttribute(LateParsedAttribute &LA,
 
   if (LA.Decls.size() > 0) {
     Decl *D = LA.Decls[0];
-    NamedDecl *ND  = dyn_cast<NamedDecl>(D);
-    RecordDecl *RD = dyn_cast_or_null<RecordDecl>(D->getDeclContext());
+    bool HasFuncScope =
+        EnterScope && LA.Decls.size() == 1 && 
D->isFunctionOrFunctionTemplate();
+    if (getLangOpts().CPlusPlus) {
----------------
rapidsna wrote:

I think we can reuse more code between C++ and C by conditionalizing the RAII 
scopes instead of branching on `getLangOpts().CPlusPlus`. Both guards already 
support a "disabled" mode:

`CXXThisScopeRAII(Sema &S, Decl *ContextDecl, Qualifiers, bool Enabled = true)` 
— no-ops when `!Enabled || !ContextDecl`
`ReenterTemplateScopeRAII(Parser &P, Decl *D, bool Enter = true)` — no-ops when 
`!Enter`

https://github.com/llvm/llvm-project/pull/186033
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to