]> granicus.if.org Git - clang/commit
[Sema] Classify conversions from enum to float as narrowing
authorMikhail Maltsev <mikhail.maltsev@arm.com>
Wed, 21 Feb 2018 10:08:18 +0000 (10:08 +0000)
committerMikhail Maltsev <mikhail.maltsev@arm.com>
Wed, 21 Feb 2018 10:08:18 +0000 (10:08 +0000)
commitab78fd585df911307fad6d5b89b0b22cb14e9001
tree766a35a1a916e0db7bee2e756991824a593b8b3e
parenteae77ccfe4a505f45e1564ba98e6fb166e92095f
[Sema] Classify conversions from enum to float as narrowing

Summary:
According to [dcl.init.list]p7:
  A narrowing conversion is an implicit conversion
  - ...
  - from an integer type or unscoped enumeration type to a
    floating-point type, except where the source is a constant
    expression and the actual value after conversion will fit into
    the target type and will produce the original value when
    converted back to the original type, or
  - ...

Currently clang does not handle the 'unscoped enumeration' case. This
patch fixes the corresponding check.

Reviewers: faisalv, rsmith, rogfer01

Reviewed By: rogfer01

Subscribers: rogfer01, cfe-commits

Differential Revision: https://reviews.llvm.org/D42545

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@325668 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Sema/SemaOverload.cpp
test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp