diff options
author | Jason Merrill <jason@redhat.com> | 2011-05-21 18:01:29 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2011-05-21 18:01:29 -0400 |
commit | 967444bbf8f78f46dd5df5c924a7650e4ad323ac (patch) | |
tree | 83ba4e68d0c082c7961e537865d4279fa9677c76 /gcc | |
parent | 525fe1cf88a56dbad47a1fcfee4e6bfe8dd3fbb4 (diff) | |
download | gcc-967444bbf8f78f46dd5df5c924a7650e4ad323ac.zip gcc-967444bbf8f78f46dd5df5c924a7650e4ad323ac.tar.gz gcc-967444bbf8f78f46dd5df5c924a7650e4ad323ac.tar.bz2 |
re PR c++/48780 ([C++0x] scoped enumerations and va_arg (default argument promotions))
PR c++/48780
* cvt.c (type_promotes_to): Don't promote scoped enums.
From-SVN: r174005
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/common.opt | 3 | ||||
-rw-r--r-- | gcc/cp/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/cp/cvt.c | 7 | ||||
-rw-r--r-- | gcc/doc/invoke.texi | 2 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/enum12.C | 18 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/enum13.C | 20 |
7 files changed, 58 insertions, 0 deletions
diff --git a/gcc/common.opt b/gcc/common.opt index ebc2ba7..492d25e 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -759,6 +759,9 @@ Driver Undocumented ; function parameters used in other parameters and the return type. ; First selectable in G++ 4.6. ; +; 6: The version of the ABI that doesn't promote scoped enums to int. +; First selectable in G++ 4.7. +; ; Additional positive integers will be assigned as new versions of ; the ABI become the default version of the ABI. fabi-version= diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 0d1968f..83c43e0 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2011-05-20 Jason Merrill <jason@redhat.com> + PR c++/48780 + * cvt.c (type_promotes_to): Don't promote scoped enums. + PR c++/49066 * decl.c (duplicate_decls): Preserve DECL_DELETED_FN. diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c index db4ea46..e5d5361 100644 --- a/gcc/cp/cvt.c +++ b/gcc/cp/cvt.c @@ -1616,6 +1616,10 @@ type_promotes_to (tree type) if (TREE_CODE (type) == BOOLEAN_TYPE) type = integer_type_node; + /* scoped enums don't promote. */ + else if (SCOPED_ENUM_P (type) && abi_version_at_least (6)) + ; + /* Normally convert enums to int, but convert wide enums to something wider. */ else if (TREE_CODE (type) == ENUMERAL_TYPE @@ -1626,6 +1630,9 @@ type_promotes_to (tree type) int precision = MAX (TYPE_PRECISION (type), TYPE_PRECISION (integer_type_node)); tree totype = c_common_type_for_size (precision, 0); + if (SCOPED_ENUM_P (type)) + warning (OPT_Wabi, "scoped enum %qT will not promote to an integral " + "type in a future version of GCC", type); if (TREE_CODE (type) == ENUMERAL_TYPE) type = ENUM_UNDERLYING_TYPE (type); if (TYPE_UNSIGNED (type) diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 46c0a70..7de8fd0 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -1839,6 +1839,8 @@ Version 5 corrects the mangling of attribute const/volatile on function pointer types, decltype of a plain decl, and use of a function parameter in the declaration of another parameter. +Version 6 corrects the promotion behavior of C++0x scoped enums. + See also @option{-Wabi}. @item -fno-access-control diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index fa4549c..9cb673b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-05-20 Jason Merrill <jason@redhat.com> + + * g++.dg/cpp0x/enum12.C: New. + * g++.dg/cpp0x/enum13.C: New. + 2011-05-21 Janus Weil <janus@gcc.gnu.org> PR fortran/48699 diff --git a/gcc/testsuite/g++.dg/cpp0x/enum12.C b/gcc/testsuite/g++.dg/cpp0x/enum12.C new file mode 100644 index 0000000..b2ec919 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/enum12.C @@ -0,0 +1,18 @@ +// PR c++/48780 +// { dg-options "-std=c++0x -fabi-version=0" } + +typedef __builtin_va_list __gnuc_va_list; +typedef __gnuc_va_list va_list; + +enum struct A : short { X }; + +void foo(int x, ...) { + va_list vl; + __builtin_va_start(vl, x); + enum A t = __builtin_va_arg(vl, enum A); + __builtin_va_end(vl); +} + +int main() { + foo(0, A::X); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/enum13.C b/gcc/testsuite/g++.dg/cpp0x/enum13.C new file mode 100644 index 0000000..ec02d3b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/enum13.C @@ -0,0 +1,20 @@ +// PR c++/48780 +// { dg-options "-std=c++0x -fabi-version=5 -Wabi" } + +typedef __builtin_va_list __gnuc_va_list; +typedef __gnuc_va_list va_list; + +enum struct A : short { X }; + +void foo(int x, ...) { + va_list vl; + __builtin_va_start(vl, x); + enum A t = __builtin_va_arg(vl, enum A); // { dg-warning "promote" } + __builtin_va_end(vl); +} + +int main() { + foo(0, A::X); // { dg-warning "will not promote" } +} + +// { dg-prune-output "note" } |