diff options
author | Paolo Carlini <paolo.carlini@oracle.com> | 2013-08-14 21:42:54 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2013-08-14 21:42:54 +0000 |
commit | 715a572a8a19d90b8dc02601adbae32a1a78652d (patch) | |
tree | 518cedf423597dcc1735e32bfb64b1b80c3f8b2f /gcc/cp | |
parent | 1869217f8819f72a210026e7d4ede7b88f40ac9e (diff) | |
download | gcc-715a572a8a19d90b8dc02601adbae32a1a78652d.zip gcc-715a572a8a19d90b8dc02601adbae32a1a78652d.tar.gz gcc-715a572a8a19d90b8dc02601adbae32a1a78652d.tar.bz2 |
re PR c++/51912 ([C++11] G++ accepts floating point case labels)
/cp
2013-08-14 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/51912
* cp-tree.h (LOOKUP_NO_NON_INTEGRAL): Add.
* decl.c (case_conversion): Use it.
* call.c (standard_conversion): Likewise.
(implicit_conversion): Adjust.
/testsuite
2013-08-14 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/51912
* g++.dg/cpp0x/enum28.C: New.
* g++.dg/cpp0x/enum15.C: Adjust.
From-SVN: r201754
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/cp/call.c | 5 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 2 | ||||
-rw-r--r-- | gcc/cp/decl.c | 4 |
4 files changed, 16 insertions, 3 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 6dd0cd8..502eecb 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,11 @@ +2013-08-14 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/51912 + * cp-tree.h (LOOKUP_NO_NON_INTEGRAL): Add. + * decl.c (case_conversion): Use it. + * call.c (standard_conversion): Likewise. + (implicit_conversion): Adjust. + 2013-08-13 Adam Butcher <adam@jessamine.co.uk> * pt.c: Grammar fix in comments ("it's" to "its"). diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 5634606..e493a79 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -1314,7 +1314,8 @@ standard_conversion (tree to, tree from, tree expr, bool c_cast_p, /* As an extension, allow conversion to complex type. */ else if (ARITHMETIC_TYPE_P (to)) { - if (! (INTEGRAL_CODE_P (fcode) || fcode == REAL_TYPE) + if (! (INTEGRAL_CODE_P (fcode) + || (fcode == REAL_TYPE && !(flags & LOOKUP_NO_NON_INTEGRAL))) || SCOPED_ENUM_P (from)) return NULL; conv = build_conv (ck_std, to, conv); @@ -1681,7 +1682,7 @@ implicit_conversion (tree to, tree from, tree expr, bool c_cast_p, resolution, or after we've chosen one. */ flags &= (LOOKUP_ONLYCONVERTING|LOOKUP_NO_CONVERSION|LOOKUP_COPY_PARM |LOOKUP_NO_TEMP_BIND|LOOKUP_NO_RVAL_BIND|LOOKUP_PREFER_RVALUE - |LOOKUP_NO_NARROWING|LOOKUP_PROTECT); + |LOOKUP_NO_NARROWING|LOOKUP_PROTECT|LOOKUP_NO_NON_INTEGRAL); /* FIXME: actually we don't want warnings either, but we can't just have 'complain &= ~(tf_warning|tf_error)' because it would cause diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 8672739..51dab8a 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -4510,6 +4510,8 @@ enum overload_flags { NO_SPECIAL = 0, DTOR_FLAG, TYPENAME_FLAG }; #define LOOKUP_EXPLICIT_TMPL_ARGS (LOOKUP_ALREADY_DIGESTED << 1) /* Like LOOKUP_NO_TEMP_BIND, but also prevent binding to xvalues. */ #define LOOKUP_NO_RVAL_BIND (LOOKUP_EXPLICIT_TMPL_ARGS << 1) +/* Used by case_conversion to disregard non-integral conversions. */ +#define LOOKUP_NO_NON_INTEGRAL (LOOKUP_NO_RVAL_BIND << 1) #define LOOKUP_NAMESPACES_ONLY(F) \ (((F) & LOOKUP_PREFER_NAMESPACES) && !((F) & LOOKUP_PREFER_TYPES)) diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 16f751c..95d5bbd 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -3103,7 +3103,9 @@ case_conversion (tree type, tree value) { if (INTEGRAL_OR_UNSCOPED_ENUMERATION_TYPE_P (type)) type = type_promotes_to (type); - value = perform_implicit_conversion (type, value, tf_warning_or_error); + value = (perform_implicit_conversion_flags + (type, value, tf_warning_or_error, + LOOKUP_IMPLICIT | LOOKUP_NO_NON_INTEGRAL)); } return cxx_constant_value (value); } |