diff options
author | ktietz <ktietz@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-05-26 16:13:55 +0000 |
---|---|---|
committer | ktietz <ktietz@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-05-26 16:13:55 +0000 |
commit | 6388cfe24f7ecbdc2ba2d4c80638ea6c95ba07c2 (patch) | |
tree | a8a266122bedc642da5d3e6dbb95526bcdf6c29d /gcc/cp | |
parent | 3df4767571f8bb21d4dffd49784f0dc0f71aea3d (diff) | |
download | gcc-6388cfe24f7ecbdc2ba2d4c80638ea6c95ba07c2.tar.gz |
libiberty/
2010-05-26 Kai Tietz <kai.tietz@onevision.com>
* testsuite/demangle-expected: Add tests for __int128
and unsigned __int128 types.
gcc/testsuite
2010-05-26 Kai Tietz <kai.tietz@onevision.com>
* lib/target-supports.exp (check_effective_target_int128): New
function to check if __int128 types are available for target.
* testsuite/c-c++-common/int128-types-1.c: New.
* testsuite/c-c++-common/int128-1.c: New.
* testsuite/c-c++-common/int128-2.c: New.
* g++.dg/abi/mangle43.C: New.
* g++.dg/init/enum1.C: Handle __int128 case and add -Wno-overflow.
* g++.dg/cpp0x/nullptr04.C: Use __SIZE_TYPE__ for getting
pointer-wide scalar.
* g++.dg/other/pr25632.C: Likewise.
* g++.dg/other/large-size-array.C (DIM): Use ULLONG_MAX for win64 case.
* g++.dg/warn/pr13358-2.C: Add llp64 for check of special
overflow warnings.
* g++.dg/warn/pr13358-4.C: Likewise.
* g++.dg/warn/Wconversion-null-2.C: Add 'long long' case.
* g++.dg/warn/Wconversion-null.C: Likewise.
gcc/
2010-05-26 Kai Tietz <kai.tietz@onevision.com>
* builtin-types.def (BT_INT128): New primitive type.
(BT_UINT128): Likewise.
* c-common.c (c_common_r): Add __int128 keyword.
(c_common_type_for_size): Handle __int128.
(c_common_type_for_mode): Likewise.
(c_common_signed_or_unsigned_type): Likewise.
(c_common_nodes_and_builtins): Add builtin type
if target supports 128-bit integer scalar.
* c-common.h (enum rid): Add RID_INT128.
* c-cppbuiltin.c (c_cpp_builtins): Define __SIZEOF_INT128__
if target supports 128-bit integer scalar.
* c-decl.c (declspecs_add_type): Handle new keyword
__int128.
(finish_declspecs): Likewise.
* c-parser.c (c_token_starts_typename): Handle RID_INT128.
(c_token_starts_declspecs): Likewise.
(c_parser_declspecs): Likewise.
(c_parser_attributes): Likewise.
(c_parser_objc_selector): Likewise.
* c-pretty-print.c (pp_c_integer_constant): Handle __int128.
* c-tree.h (enum c_typespec_keyword): Add cts_int128.
* gimple.c (gimple_signed_or_unsigned_type): Handle int128 types.
* tree.c (make_or_reuse_type): Likewise.
(make_unsigned_type): Likewise.
(build_common_tree_nodes_2): Likewise.
* tree.h (enum integer_type_kind): Add itk_int128 and
itk_unsigned_int128.
(int128_integer_type_node): New define..
(int128_unsigned_type_node): New define.
* cp/cp-tree.h (cp_decl_specifier_seq): Add new bifield
explicit_int128_p.
* cp/decl.c (grokdeclarator): Handle __int128.
* cp/parser.c (cp_lexer_next_token_is_decl_specifier_ke): Likewise.
(cp_parser_simple_type_specifier): Likewise.
* cp/rtti.c (emit_support_tinfos): Add int128 nodes for rtti.
* cp/typeck.c (cp_common_type): Handle __int128.
* cp/mangle.c (integer_type_codes): Add itk_int128 and
itk_unsigned_int128.
* doc/extend.texi: Add documentation about __int128 type.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@159879 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/cp-tree.h | 2 | ||||
-rw-r--r-- | gcc/cp/decl.c | 34 | ||||
-rw-r--r-- | gcc/cp/mangle.c | 4 | ||||
-rw-r--r-- | gcc/cp/parser.c | 9 | ||||
-rw-r--r-- | gcc/cp/rtti.c | 1 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 11 |
6 files changed, 56 insertions, 5 deletions
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 3128ad3766a..37a0f1e50ea 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -4402,6 +4402,8 @@ typedef struct cp_decl_specifier_seq { BOOL_BITFIELD any_type_specifiers_p : 1; /* True iff "int" was explicitly provided. */ BOOL_BITFIELD explicit_int_p : 1; + /* True iff "__int128" was explicitly provided. */ + BOOL_BITFIELD explicit_int128_p : 1; /* True iff "char" was explicitly provided. */ BOOL_BITFIELD explicit_char_p : 1; } cp_decl_specifier_seq; diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 0a444d29118..495660dec29 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -7701,6 +7701,7 @@ grokdeclarator (const cp_declarator *declarator, { tree type = NULL_TREE; int longlong = 0; + int explicit_int128 = 0; int virtualp, explicitp, friendp, inlinep, staticp; int explicit_int = 0; int explicit_char = 0; @@ -7764,6 +7765,7 @@ grokdeclarator (const cp_declarator *declarator, short_p = declspecs->specs[(int)ds_short]; long_p = declspecs->specs[(int)ds_long]; longlong = declspecs->specs[(int)ds_long] >= 2; + explicit_int128 = declspecs->explicit_int128_p; thread_p = declspecs->specs[(int)ds_thread]; if (decl_context == FUNCDEF) @@ -8092,12 +8094,16 @@ grokdeclarator (const cp_declarator *declarator, error ("%<signed%> and %<unsigned%> specified together for %qs", name); else if (longlong && TREE_CODE (type) != INTEGER_TYPE) error ("%<long long%> invalid for %qs", name); + else if (explicit_int128 && TREE_CODE (type) != INTEGER_TYPE) + error ("%<__int128%> invalid for %qs", name); else if (long_p && TREE_CODE (type) == REAL_TYPE) error ("%<long%> invalid for %qs", name); else if (short_p && TREE_CODE (type) == REAL_TYPE) error ("%<short%> invalid for %qs", name); else if ((long_p || short_p) && TREE_CODE (type) != INTEGER_TYPE) error ("%<long%> or %<short%> invalid for %qs", name); + else if ((long_p || short_p || explicit_char || explicit_int) && explicit_int128) + error ("%<long%>, %<int%>, %<short%>, or %<char%> invalid for %qs", name); else if ((long_p || short_p) && explicit_char) error ("%<long%> or %<short%> specified with char for %qs", name); else if (long_p && short_p) @@ -8112,7 +8118,7 @@ grokdeclarator (const cp_declarator *declarator, else { ok = 1; - if (!explicit_int && !defaulted_int && !explicit_char && pedantic) + if (!explicit_int && !defaulted_int && !explicit_char && !explicit_int128 && pedantic) { pedwarn (input_location, OPT_pedantic, "long, short, signed or unsigned used invalidly for %qs", @@ -8120,6 +8126,22 @@ grokdeclarator (const cp_declarator *declarator, if (flag_pedantic_errors) ok = 0; } + if (explicit_int128) + { + if (int128_integer_type_node == NULL_TREE) + { + error ("%<__int128%> is not supported by this target"); + ok = 0; + } + else if (pedantic) + { + pedwarn (input_location, OPT_pedantic, + "ISO C++ does not support %<__int128%> for %qs", + name); + if (flag_pedantic_errors) + ok = 0; + } + } } /* Discard the type modifiers if they are invalid. */ @@ -8130,6 +8152,7 @@ grokdeclarator (const cp_declarator *declarator, long_p = false; short_p = false; longlong = 0; + explicit_int128 = false; } } @@ -8154,7 +8177,9 @@ grokdeclarator (const cp_declarator *declarator, && TREE_CODE (type) == INTEGER_TYPE && !same_type_p (TYPE_MAIN_VARIANT (type), wchar_type_node))) { - if (longlong) + if (explicit_int128) + type = int128_unsigned_type_node; + else if (longlong) type = long_long_unsigned_type_node; else if (long_p) type = long_unsigned_type_node; @@ -8169,6 +8194,8 @@ grokdeclarator (const cp_declarator *declarator, } else if (signed_p && type == char_type_node) type = signed_char_type_node; + else if (explicit_int128) + type = int128_integer_type_node; else if (longlong) type = long_long_integer_type_node; else if (long_p) @@ -8184,8 +8211,7 @@ grokdeclarator (const cp_declarator *declarator, "complex double", but if any modifiers at all are specified it is the complex form of TYPE. E.g, "complex short" is "complex short int". */ - - else if (defaulted_int && ! longlong + else if (defaulted_int && ! longlong && ! explicit_int128 && ! (long_p || short_p || signed_p || unsigned_p)) type = complex_double_type_node; else if (type == integer_type_node) diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c index 89ccbaf3f0c..a8a80a9b535 100644 --- a/gcc/cp/mangle.c +++ b/gcc/cp/mangle.c @@ -148,7 +148,9 @@ integer_type_codes[itk_none] = 'l', /* itk_long */ 'm', /* itk_unsigned_long */ 'x', /* itk_long_long */ - 'y' /* itk_unsigned_long_long */ + 'y', /* itk_unsigned_long_long */ + 'n', /* itk_int128 */ + 'o', /* itk_unsigned_int128 */ }; static int decl_is_template_id (const tree, tree* const); diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 1cfdba7f20e..36d7eae5883 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -682,6 +682,7 @@ cp_lexer_next_token_is_decl_specifier_keyword (cp_lexer *lexer) case RID_SHORT: case RID_INT: case RID_LONG: + case RID_INT128: case RID_SIGNED: case RID_UNSIGNED: case RID_FLOAT: @@ -12164,6 +12165,7 @@ cp_parser_type_specifier (cp_parser* parser, GNU Extension: simple-type-specifier: + __int128 __typeof__ unary-expression __typeof__ ( type-id ) @@ -12211,6 +12213,13 @@ cp_parser_simple_type_specifier (cp_parser* parser, decl_specs->explicit_int_p = true; type = integer_type_node; break; + case RID_INT128: + if (!int128_integer_type_node) + break; + if (decl_specs) + decl_specs->explicit_int128_p = true; + type = int128_integer_type_node; + break; case RID_LONG: if (decl_specs) ++decl_specs->specs[(int) ds_long]; diff --git a/gcc/cp/rtti.c b/gcc/cp/rtti.c index 3ffd097946a..17664f57ed5 100644 --- a/gcc/cp/rtti.c +++ b/gcc/cp/rtti.c @@ -1476,6 +1476,7 @@ emit_support_tinfos (void) &integer_type_node, &unsigned_type_node, &long_integer_type_node, &long_unsigned_type_node, &long_long_integer_type_node, &long_long_unsigned_type_node, + &int128_integer_type_node, &int128_unsigned_type_node, &float_type_node, &double_type_node, &long_double_type_node, &dfloat32_type_node, &dfloat64_type_node, &dfloat128_type_node, &nullptr_type_node, diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index d819c7fcfb9..4ad93494d18 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -350,6 +350,17 @@ cp_common_type (tree t1, tree t2) : long_long_integer_type_node); return build_type_attribute_variant (t, attributes); } + if (int128_integer_type_node != NULL_TREE + && (same_type_p (TYPE_MAIN_VARIANT (t1), + int128_integer_type_node) + || same_type_p (TYPE_MAIN_VARIANT (t2), + int128_integer_type_node))) + { + tree t = ((TYPE_UNSIGNED (t1) || TYPE_UNSIGNED (t2)) + ? int128_unsigned_type_node + : int128_integer_type_node); + return build_type_attribute_variant (t, attributes); + } /* Go through the same procedure, but for longs. */ if (same_type_p (TYPE_MAIN_VARIANT (t1), long_unsigned_type_node) |