diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-01-18 05:21:49 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-01-18 05:21:49 +0000 |
commit | 4c3fc9b38d3723f73e4ded594cebf38c76f91d93 (patch) | |
tree | cdba7956c4da548d2d932d58a1e99b14be707e05 /include/clang/Sema/Overload.h | |
parent | 8013afe5752551d72d290991046c3942138d2df1 (diff) |
Move narrowing conversion detection code from SemaInit to SemaOverload, ready
for it to be used in converted constant expression checking, and fix a couple
of issues:
- Conversion operators implicitly invoked prior to the narrowing conversion
were not being correctly handled when determining whether a constant value
was narrowed.
- For conversions from floating-point to integral types, the diagnostic text
incorrectly always claimed that the source expression was not a constant
expression.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148381 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Sema/Overload.h')
-rw-r--r-- | include/clang/Sema/Overload.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/include/clang/Sema/Overload.h b/include/clang/Sema/Overload.h index 3fcc56790c..9a3397d235 100644 --- a/include/clang/Sema/Overload.h +++ b/include/clang/Sema/Overload.h @@ -112,6 +112,23 @@ namespace clang { ImplicitConversionRank GetConversionRank(ImplicitConversionKind Kind); + /// NarrowingKind - The kind of narrowing conversion being performed by a + /// standard conversion sequence according to C++11 [dcl.init.list]p7. + enum NarrowingKind { + /// Not a narrowing conversion. + NK_Not_Narrowing, + + /// A narrowing conversion by virtue of the source and destination types. + NK_Type_Narrowing, + + /// A narrowing conversion, because a constant expression got narrowed. + NK_Constant_Narrowing, + + /// A narrowing conversion, because a non-constant-expression variable might + /// have got narrowed. + NK_Variable_Narrowing + }; + /// StandardConversionSequence - represents a standard conversion /// sequence (C++ 13.3.3.1.1). A standard conversion sequence /// contains between zero and three conversions. If a particular @@ -218,6 +235,8 @@ namespace clang { } ImplicitConversionRank getRank() const; + NarrowingKind isNarrowing(ASTContext &Context, const Expr *Converted, + APValue &ConstantValue) const; bool isPointerConversionToBool() const; bool isPointerConversionToVoidPointer(ASTContext& Context) const; void DebugPrint() const; |