From f46e2bc9236de506841dca92414b217a1d90bbea Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Sun, 19 Feb 2017 17:43:41 +0000 Subject: [PATCH] =?utf8?q?re=20PR=20c++/79380=20(ICE=20on=20C++11=20code?= =?utf8?q?=20with=20illegal=20alignas=20specifier=20on=20x86=5F64-linux-gn?= =?utf8?q?u:=20unexpected=20expression=20=E2=80=98f=E2=80=99=20of=20kind?= =?utf8?q?=20overload)?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit /cp 2017-02-19 Paolo Carlini PR c++/79380 * typeck.c (cxx_alignas_expr): Reject a non-integral alignas argument. /testsuite 2017-02-19 Paolo Carlini PR c++/79380 * g++.dg/cpp0x/alignas8.C: New. From-SVN: r245578 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/typeck.c | 6 ++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/cpp0x/alignas8.C | 7 +++++++ 4 files changed, 24 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp0x/alignas8.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index d0803bf..20c7eed 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2017-02-19 Paolo Carlini + + PR c++/79380 + * typeck.c (cxx_alignas_expr): Reject a non-integral alignas + argument. + 2017-02-19 Eric Fiselier Jonathan Wakely diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 87e7cc0..9297a99a 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -1795,6 +1795,12 @@ cxx_alignas_expr (tree e) the assignment-expression shall be an integral constant expression. */ + + if (!INTEGRAL_OR_UNSCOPED_ENUMERATION_TYPE_P (TREE_TYPE (e))) + { + error ("% argument has non-integral type %qT", TREE_TYPE (e)); + return error_mark_node; + } return cxx_constant_value (e); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c98d774..097cab4 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-02-19 Paolo Carlini + + PR c++/79380 + * g++.dg/cpp0x/alignas8.C: New. + 2017-02-19 Eric Fiselier Jonathan Wakely diff --git a/gcc/testsuite/g++.dg/cpp0x/alignas8.C b/gcc/testsuite/g++.dg/cpp0x/alignas8.C new file mode 100644 index 0000000..bd76233 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/alignas8.C @@ -0,0 +1,7 @@ +// PR c++/79380 +// { dg-do compile { target c++11 } } + +template < typename > constexpr int f () { return 8; } + +// should have been: struct alignas (f()) S {}; +struct alignas (f) S {}; // { dg-error "17:'alignas' argument has non-integral type" } -- 2.7.4