diff options
author | Paolo Carlini <paolo.carlini@oracle.com> | 2014-09-02 15:38:38 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2014-09-02 15:38:38 +0000 |
commit | cec362c90b53bec41a0571220216401978b3a6ad (patch) | |
tree | df50e30837aebdb34f1d08244a305e8c27331c26 | |
parent | 4e2b2eeec93479e9a6ecde090e7b748fabcae107 (diff) | |
download | gcc-cec362c90b53bec41a0571220216401978b3a6ad.zip gcc-cec362c90b53bec41a0571220216401978b3a6ad.tar.gz gcc-cec362c90b53bec41a0571220216401978b3a6ad.tar.bz2 |
DR 1453
/cp
2014-09-02 Paolo Carlini <paolo.carlini@oracle.com>
DR 1453
* class.c (check_field_decls): A class of literal type cannot have
volatile non-static data members and base classes.
(explain_non_literal_class): Update.
/testsuite
2014-09-02 Paolo Carlini <paolo.carlini@oracle.com>
DR 1453
* g++.dg/cpp0x/constexpr-volatile.C: New.
* g++.dg/ext/is_literal_type2.C: Likewise.
From-SVN: r214823
-rw-r--r-- | gcc/cp/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/cp/class.c | 11 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/constexpr-volatile.C | 26 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/ext/is_literal_type2.C | 26 |
5 files changed, 73 insertions, 3 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 7a72097..258fd9b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2014-09-02 Paolo Carlini <paolo.carlini@oracle.com> + + DR 1453 + * class.c (check_field_decls): A class of literal type cannot have + volatile non-static data members and base classes. + (explain_non_literal_class): Update. + 2014-09-02 Jakub Jelinek <jakub@redhat.com> Balaji V. Iyer <balaji.v.iyer@intel.com> Igor Zamyatin <igor.zamyatin@intel.com> diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 5c9a9a7..09f946f 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -3528,9 +3528,11 @@ check_field_decls (tree t, tree *access_decls, CLASSTYPE_NON_AGGREGATE (t) = 1; /* If at least one non-static data member is non-literal, the whole - class becomes non-literal. Note: if the type is incomplete we - will complain later on. */ - if (COMPLETE_TYPE_P (type) && !literal_type_p (type)) + class becomes non-literal. Per Core/1453, volatile non-static + data members and base classes are also not allowed. + Note: if the type is incomplete we will complain later on. */ + if (COMPLETE_TYPE_P (type) + && (!literal_type_p (type) || CP_TYPE_VOLATILE_P (type))) CLASSTYPE_LITERAL_P (t) = false; /* A standard-layout class is a class that: @@ -5431,6 +5433,9 @@ explain_non_literal_class (tree t) if (CLASS_TYPE_P (ftype)) explain_non_literal_class (ftype); } + if (CP_TYPE_VOLATILE_P (ftype)) + inform (0, " non-static data member %q+D has " + "volatile type", field); } } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7281fd9..0bffdb0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2014-09-02 Paolo Carlini <paolo.carlini@oracle.com> + + DR 1453 + * g++.dg/cpp0x/constexpr-volatile.C: New. + * g++.dg/ext/is_literal_type2.C: Likewise. + 2014-09-02 Jakub Jelinek <jakub@redhat.com> Balaji V. Iyer <balaji.v.iyer@intel.com> Igor Zamyatin <igor.zamyatin@intel.com> diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-volatile.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-volatile.C new file mode 100644 index 0000000..1203b04 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-volatile.C @@ -0,0 +1,26 @@ +// DR 1453 +// { dg-do compile { target c++11 } } + +struct S { + constexpr S() : n{} { } + volatile int n; +}; + +constexpr S s; // { dg-error "literal" } + +struct Z { + volatile int m; +}; + +struct T { + constexpr T() : n{} { } + Z n; +}; + +constexpr T t; // { dg-error "literal" } + +struct U : Z { + constexpr U() : Z{} { } +}; + +constexpr U u; // { dg-error "literal" } diff --git a/gcc/testsuite/g++.dg/ext/is_literal_type2.C b/gcc/testsuite/g++.dg/ext/is_literal_type2.C new file mode 100644 index 0000000..8a0632b --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/is_literal_type2.C @@ -0,0 +1,26 @@ +// DR 1453 +// { dg-do compile { target c++11 } } + +struct S { + constexpr S() : n{} { } + volatile int n; +}; + +static_assert(!__is_literal_type(S), ""); + +struct Z { + volatile int m; +}; + +struct T { + constexpr T() : n{} { } + Z n; +}; + +static_assert(!__is_literal_type(T), ""); + +struct U : Z { + constexpr U() : Z{} { } +}; + +static_assert(!__is_literal_type(U), ""); |