diff options
Diffstat (limited to 'meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0401-PR-c-48780.patch')
-rw-r--r-- | meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0401-PR-c-48780.patch | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0401-PR-c-48780.patch b/meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0401-PR-c-48780.patch new file mode 100644 index 0000000000..d896acf603 --- /dev/null +++ b/meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0401-PR-c-48780.patch | |||
@@ -0,0 +1,63 @@ | |||
1 | From 06d3ff4b37b05f4f4f2295222ae3d2818eb8232b Mon Sep 17 00:00:00 2001 | ||
2 | From: jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | ||
3 | Date: Tue, 7 Jun 2011 15:12:15 +0000 | ||
4 | Subject: [PATCH] PR c++/48780 | ||
5 | * typeck.c (perform_integral_promotions): Don't promote scoped enums. | ||
6 | * call.c (convert_arg_to_ellipsis): Promote them here in old ABI. | ||
7 | |||
8 | git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_6-branch@174753 138bc75d-0d04-0410-961f-82ee72b054a4 | ||
9 | |||
10 | index 246fb6d..7019da9 100644 | ||
11 | --- a/gcc/cp/call.c | ||
12 | +++ b/gcc/cp/call.c | ||
13 | @@ -5724,7 +5724,15 @@ convert_arg_to_ellipsis (tree arg) | ||
14 | else if (NULLPTR_TYPE_P (arg_type)) | ||
15 | arg = null_pointer_node; | ||
16 | else if (INTEGRAL_OR_ENUMERATION_TYPE_P (arg_type)) | ||
17 | - arg = perform_integral_promotions (arg); | ||
18 | + { | ||
19 | + if (SCOPED_ENUM_P (arg_type) && !abi_version_at_least (6)) | ||
20 | + { | ||
21 | + warning (OPT_Wabi, "scoped enum %qT will not promote to an " | ||
22 | + "integral type in a future version of GCC", arg_type); | ||
23 | + arg = cp_convert (ENUM_UNDERLYING_TYPE (arg_type), arg); | ||
24 | + } | ||
25 | + arg = perform_integral_promotions (arg); | ||
26 | + } | ||
27 | |||
28 | arg = require_complete_type (arg); | ||
29 | arg_type = TREE_TYPE (arg); | ||
30 | diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c | ||
31 | index 2022f0f..6214452 100644 | ||
32 | --- a/gcc/cp/typeck.c | ||
33 | +++ b/gcc/cp/typeck.c | ||
34 | @@ -1946,6 +1946,9 @@ perform_integral_promotions (tree expr) | ||
35 | if (!type || TREE_CODE (type) != ENUMERAL_TYPE) | ||
36 | type = TREE_TYPE (expr); | ||
37 | gcc_assert (INTEGRAL_OR_ENUMERATION_TYPE_P (type)); | ||
38 | + /* Scoped enums don't promote. */ | ||
39 | + if (SCOPED_ENUM_P (type)) | ||
40 | + return expr; | ||
41 | promoted_type = type_promotes_to (type); | ||
42 | if (type != promoted_type) | ||
43 | expr = cp_convert (promoted_type, expr); | ||
44 | new file mode 100644 | ||
45 | index 0000000..acdd86c | ||
46 | --- /dev/null | ||
47 | +++ b/gcc/testsuite/g++.dg/cpp0x/enum19.C | ||
48 | @@ -0,0 +1,12 @@ | ||
49 | +// We shouldn't give an ABI warning about promotion in switch. | ||
50 | +// { dg-options "-std=c++0x -fabi-version=5 -Wabi" } | ||
51 | + | ||
52 | +enum class Foo { X }; | ||
53 | +void test(Foo val) | ||
54 | +{ | ||
55 | + switch(val) | ||
56 | + { | ||
57 | + case Foo::X: | ||
58 | + break; | ||
59 | + } | ||
60 | +}; | ||
61 | -- | ||
62 | 1.7.0.4 | ||
63 | |||