diff options
author | Keith Seitz <keiths@redhat.com> | 2012-09-10 17:12:46 +0000 |
---|---|---|
committer | Keith Seitz <keiths@redhat.com> | 2012-09-10 17:12:46 +0000 |
commit | cd74c0d3d11914f2b9b763ea2164b7e9c83c1230 (patch) | |
tree | 882190200f458efec5b02f0a34eb70d82d027a42 /gdb/gdbtypes.c | |
parent | 6d07ce03bd1b3d25257ad428d991bb411b71e082 (diff) | |
download | gdb-cd74c0d3d11914f2b9b763ea2164b7e9c83c1230.tar.gz |
PR gdb/13483
* gdbtypes.h (BOOL_PTR_CONVERSION_BADNESS): Rename to ...
(BOOL_CONVERSION_BADNESS): ... this.
* gdbtypes.c (BOOL_PTR_CONVERSION_BADNESS): Likewise.
(rank_one_type): Allow all boolean conversions
permitted by the standard.
* gdb.cp/converts.cc (A::A): Add ctor.
(A::member_): Add member.
(enum my_enum): New enumeration.
(main): Add calls to foo1_7 with various
permitted arguments.
* gdb.cp/converts.exp: Add tests for boolean
conversions permitted by the standard.
Diffstat (limited to 'gdb/gdbtypes.c')
-rw-r--r-- | gdb/gdbtypes.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 21d9043a138..8ac87997065 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -54,7 +54,7 @@ const struct rank INTEGER_CONVERSION_BADNESS = {2,0}; const struct rank FLOAT_CONVERSION_BADNESS = {2,0}; const struct rank INT_FLOAT_CONVERSION_BADNESS = {2,0}; const struct rank VOID_PTR_CONVERSION_BADNESS = {2,0}; -const struct rank BOOL_PTR_CONVERSION_BADNESS = {3,0}; +const struct rank BOOL_CONVERSION_BADNESS = {3,0}; const struct rank BASE_CONVERSION_BADNESS = {2,0}; const struct rank REFERENCE_CONVERSION_BADNESS = {2,0}; const struct rank NULL_POINTER_CONVERSION_BADNESS = {2,0}; @@ -2718,14 +2718,23 @@ rank_one_type (struct type *parm, struct type *arg, struct value *value) case TYPE_CODE_BOOL: switch (TYPE_CODE (arg)) { + /* n3290 draft, section 4.12.1 (conv.bool): + + "A prvalue of arithmetic, unscoped enumeration, pointer, or + pointer to member type can be converted to a prvalue of type + bool. A zero value, null pointer value, or null member pointer + value is converted to false; any other value is converted to + true. A prvalue of type std::nullptr_t can be converted to a + prvalue of type bool; the resulting value is false." */ case TYPE_CODE_INT: case TYPE_CODE_CHAR: - case TYPE_CODE_RANGE: case TYPE_CODE_ENUM: case TYPE_CODE_FLT: - return INCOMPATIBLE_TYPE_BADNESS; + case TYPE_CODE_MEMBERPTR: case TYPE_CODE_PTR: - return BOOL_PTR_CONVERSION_BADNESS; + return BOOL_CONVERSION_BADNESS; + case TYPE_CODE_RANGE: + return INCOMPATIBLE_TYPE_BADNESS; case TYPE_CODE_BOOL: return EXACT_MATCH_BADNESS; default: |