Skip to content

Diagnostic is not specific enough when when scoped enumeration requires a explicit conversion for binary operations  #24265

@chandlerc

Description

@chandlerc
Bugzilla Link 23891
Version unspecified
OS All
CC @DougGregor,@Weverything

Extended Description

I just got the worst syntax error message I've seen in a long time:

In file included from ../lib/CodeGen/PostRASchedulerList.cpp:27:
../include/llvm/Analysis/AliasAnalysis.h:129:57: error: invalid operands to binary expression ('llvm::FunctionModRefLocation' and 'llvm::ModRefInfo')
  DoesNotAccessMemory = FunctionModRefLocation::Nowhere | ModRefInfo::NoModRef,
                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~
../include/llvm/Analysis/AliasAnalysis.h:137:48: error: invalid operands to binary expression ('llvm::FunctionModRefLocation' and 'llvm::ModRefInfo')
      FunctionModRefLocation::ArgumentPointees | ModRefInfo::Ref,
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~
../include/llvm/Analysis/AliasAnalysis.h:145:48: error: invalid operands to binary expression ('llvm::FunctionModRefLocation' and 'llvm::ModRefInfo')
      FunctionModRefLocation::ArgumentPointees | ModRefInfo::ModRef,
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~
../include/llvm/Analysis/AliasAnalysis.h:153:54: error: invalid operands to binary expression ('llvm::FunctionModRefLocation' and 'llvm::ModRefInfo')
  OnlyReadsMemory = FunctionModRefLocation::Anywhere | ModRefInfo::Ref,
                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~

The bug is that these are scoped enumerations and so there is no | operator (it would require an implicit conversion to int). But the error message literally tells me nothing other than that there is an error. =[ =[ =[

Metadata

Metadata

Assignees

Labels

bugzillaIssues migrated from bugzillac++clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzergood first issuehttps://github.com/llvm/llvm-project/contribute

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions