File tree 1 file changed +12
-0
lines changed 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -1254,6 +1254,18 @@ Parser::DeclGroupPtrTy Parser::ParseDeclarationOrFunctionDefinition(
1254
1254
Actions.getASTContext ().getSourceManager ());
1255
1255
});
1256
1256
1257
+ if (DS->getStorageClassSpec () != DeclSpec::SCS_unspecified) {
1258
+ // Check if the next token starts a class/struct/union/enum declaration
1259
+ if (Tok.isOneOf (tok::kw_class, tok::kw_struct, tok::kw_union, tok::kw_enum)) {
1260
+ // Emit an error: storage class specifiers are not allowed before class declarations
1261
+ Diag (DS->getStorageClassSpecLoc (), diag::err_storage_class_before_class_decl)
1262
+ << DeclSpec::getSpecifierName (DS->getStorageClassSpec ());
1263
+
1264
+ // Optionally, consume the storage class specifier to continue parsing
1265
+ DS->ClearStorageClassSpecs ();
1266
+ }
1267
+ }
1268
+
1257
1269
if (DS) {
1258
1270
return ParseDeclOrFunctionDefInternal (Attrs, DeclSpecAttrs, *DS, AS);
1259
1271
} else {
You can’t perform that action at this time.
0 commit comments