Skip to content

Commit fe8e703

Browse files
authored
[clang][Parse] Use consistent Scope::ScopeFlags enum values (NFC) (#159275)
Commit 438863a changed the underlying type of the Scope::ScopeFlags from int to unsigned. This triggers type mismatch warnings from specific compilers when the enum's values are combined in operations with integer literal 0. Regardless of these warnings, similar code in other places uses Scope::NoScope instead of literal 0. For consistency and to avoid these warnings, we change the uses of literal 0 to Scope::NoScope.
1 parent ce51248 commit fe8e703

File tree

3 files changed

+16
-15
lines changed

3 files changed

+16
-15
lines changed

clang/lib/Parse/ParseDecl.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6813,10 +6813,10 @@ void Parser::ParseDirectDeclarator(Declarator &D) {
68136813
bool IsFunctionDeclaration = D.isFunctionDeclaratorAFunctionDeclaration();
68146814
// Enter function-declaration scope, limiting any declarators to the
68156815
// function prototype scope, including parameter declarators.
6816-
ParseScope PrototypeScope(this,
6817-
Scope::FunctionPrototypeScope|Scope::DeclScope|
6818-
(IsFunctionDeclaration
6819-
? Scope::FunctionDeclarationScope : 0));
6816+
ParseScope PrototypeScope(
6817+
this, Scope::FunctionPrototypeScope | Scope::DeclScope |
6818+
(IsFunctionDeclaration ? Scope::FunctionDeclarationScope
6819+
: Scope::NoScope));
68206820

68216821
// The paren may be part of a C++ direct initializer, eg. "int x(1);".
68226822
// In such a case, check if we actually have a function declarator; if it
@@ -7097,8 +7097,9 @@ void Parser::ParseParenDeclarator(Declarator &D) {
70977097
// function prototype scope, including parameter declarators.
70987098
ParseScope PrototypeScope(this,
70997099
Scope::FunctionPrototypeScope | Scope::DeclScope |
7100-
(D.isFunctionDeclaratorAFunctionDeclaration()
7101-
? Scope::FunctionDeclarationScope : 0));
7100+
(D.isFunctionDeclaratorAFunctionDeclaration()
7101+
? Scope::FunctionDeclarationScope
7102+
: Scope::NoScope));
71027103
ParseFunctionDeclarator(D, attrs, T, false, RequiresArg);
71037104
PrototypeScope.Exit();
71047105
}

clang/lib/Parse/ParseObjc.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3295,9 +3295,9 @@ void Parser::ParseLexedObjCMethodDefs(LexedMethod &LM, bool parseMethod) {
32953295
assert(Tok.isOneOf(tok::l_brace, tok::kw_try, tok::colon) &&
32963296
"Inline objective-c method not starting with '{' or 'try' or ':'");
32973297
// Enter a scope for the method or c-function body.
3298-
ParseScope BodyScope(this, (parseMethod ? Scope::ObjCMethodScope : 0) |
3299-
Scope::FnScope | Scope::DeclScope |
3300-
Scope::CompoundStmtScope);
3298+
ParseScope BodyScope(
3299+
this, (parseMethod ? Scope::ObjCMethodScope : Scope::NoScope) |
3300+
Scope::FnScope | Scope::DeclScope | Scope::CompoundStmtScope);
33013301
Sema::FPFeaturesStateRAII SaveFPFeatures(Actions);
33023302

33033303
// Tell the actions module that we have entered a method or c-function definition

clang/lib/Parse/ParseStmt.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2529,9 +2529,9 @@ StmtResult Parser::ParseCXXTryBlockCommon(SourceLocation TryLoc, bool FnTry) {
25292529
return StmtError(Diag(Tok, diag::err_expected) << tok::l_brace);
25302530

25312531
StmtResult TryBlock(ParseCompoundStatement(
2532-
/*isStmtExpr=*/false, Scope::DeclScope | Scope::TryScope |
2533-
Scope::CompoundStmtScope |
2534-
(FnTry ? Scope::FnTryCatchScope : 0)));
2532+
/*isStmtExpr=*/false,
2533+
Scope::DeclScope | Scope::TryScope | Scope::CompoundStmtScope |
2534+
(FnTry ? Scope::FnTryCatchScope : Scope::NoScope)));
25352535
if (TryBlock.isInvalid())
25362536
return TryBlock;
25372537

@@ -2593,9 +2593,9 @@ StmtResult Parser::ParseCXXCatchBlock(bool FnCatch) {
25932593
// C++ 3.3.2p3:
25942594
// The name in a catch exception-declaration is local to the handler and
25952595
// shall not be redeclared in the outermost block of the handler.
2596-
ParseScope CatchScope(this, Scope::DeclScope | Scope::ControlScope |
2597-
Scope::CatchScope |
2598-
(FnCatch ? Scope::FnTryCatchScope : 0));
2596+
ParseScope CatchScope(
2597+
this, Scope::DeclScope | Scope::ControlScope | Scope::CatchScope |
2598+
(FnCatch ? Scope::FnTryCatchScope : Scope::NoScope));
25992599

26002600
// exception-declaration is equivalent to '...' or a parameter-declaration
26012601
// without default arguments.

0 commit comments

Comments
 (0)