diff options
author | Mark Mitchell <mark@codesourcery.com> | 2007-03-12 00:26:39 +0000 |
---|---|---|
committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 2007-03-12 00:26:39 +0000 |
commit | 3c38f0ff2e34900a89268b0880c9b8e33cdce715 (patch) | |
tree | e8f2a57a999cd544124fd9b8e1410f55c4e85e82 | |
parent | efb84847dfc11e5fb694c984f5421562bcc200f8 (diff) | |
download | gcc-3c38f0ff2e34900a89268b0880c9b8e33cdce715.zip gcc-3c38f0ff2e34900a89268b0880c9b8e33cdce715.tar.gz gcc-3c38f0ff2e34900a89268b0880c9b8e33cdce715.tar.bz2 |
re PR c++/30328 (bit-field: unassemblable assembly code)
PR c++/30328
* semantics.c (finish_typeof): Use unlowered_expr_type.
PR c++/30328
* g++.dg/ext/bitfield1.C: New test.
PR c++/31038
* parser.c (cp_parser_postfix_expression): Disallow compound
literals in constant expressions.
PR c++/31038
* g++.dg/template/complit2.C: New test.
From-SVN: r122829
-rw-r--r-- | gcc/cp/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/cp/parser.c | 15 | ||||
-rw-r--r-- | gcc/cp/semantics.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/ext/bitfield1.C | 22 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/complit2.C | 17 |
6 files changed, 72 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 2f9b251..acc6435 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,12 @@ +2007-03-11 Mark Mitchell <mark@codesourcery.com> + + PR c++/31038 + * parser.c (cp_parser_postfix_expression): Disallow compound + literals in constant expressions. + + PR c++/30328 + * semantics.c (finish_typeof): Use unlowered_expr_type. + 2007-03-10 Mark Mitchell <mark@codesourcery.com> PR c++/30274 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index f81fbdf..54c7668 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -4343,6 +4343,21 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p) allowed in standard C++. */ if (pedantic) pedwarn ("ISO C++ forbids compound-literals"); + /* For simplicitly, we disallow compound literals in + constant-expressions for simpliicitly. We could + allow compound literals of integer type, whose + initializer was a constant, in constant + expressions. Permitting that usage, as a further + extension, would not change the meaning of any + currently accepted programs. (Of course, as + compound literals are not part of ISO C++, the + standard has nothing to say.) */ + if (cp_parser_non_integral_constant_expression + (parser, "non-constant compound literals")) + { + postfix_expression = error_mark_node; + break; + } /* Form the representation of the compound-literal. */ postfix_expression = finish_compound_literal (type, initializer_list); diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index f63ed2f..e016b0a 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -2927,7 +2927,7 @@ finish_typeof (tree expr) return type; } - type = TREE_TYPE (expr); + type = unlowered_expr_type (expr); if (!type || type == unknown_type_node) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2276ea0..fb51c23 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2007-03-11 Mark Mitchell <mark@codesourcery.com> + + PR c++/31038 + * g++.dg/template/complit2.C: New test. + + PR c++/30328 + * g++.dg/ext/bitfield1.C: New test. + 2007-03-11 Paul Thomas <pault@gcc.gnu.org> PR fortran/30883 diff --git a/gcc/testsuite/g++.dg/ext/bitfield1.C b/gcc/testsuite/g++.dg/ext/bitfield1.C new file mode 100644 index 0000000..25c90df --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/bitfield1.C @@ -0,0 +1,22 @@ +// PR c++/30328 +// { dg-do link } +// { dg-options "" } + +struct S +{ + signed int a:17; +} x; + +typedef typeof (x.a) foo; + +template <class T> +T* inc(T* p) { return p+1; } + +int main () +{ + foo x[2] = { 1,2 }; + int y[2] = { 1,2 }; + *inc(x); + *inc(y); + return 0; +} diff --git a/gcc/testsuite/g++.dg/template/complit2.C b/gcc/testsuite/g++.dg/template/complit2.C new file mode 100644 index 0000000..cf3856d --- /dev/null +++ b/gcc/testsuite/g++.dg/template/complit2.C @@ -0,0 +1,17 @@ +// PR c++/31038 +// { dg-options "" } + +template<int> void foo() +{ + int i = (int) { 0 }; +} + +template void foo<0>(); +int f(); + +template<int> void bar() +{ + int i = (int) { f() }; +} + +template void bar<0>(); |