From: Paolo Carlini Date: Sun, 19 Feb 2017 17:43:41 +0000 (+0000) Subject: re PR c++/79380 (ICE on C++11 code with illegal alignas specifier on x86_64-linux... X-Git-Tag: upstream/12.2.0~41100 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f46e2bc9236de506841dca92414b217a1d90bbea;p=platform%2Fupstream%2Fgcc.git re PR c++/79380 (ICE on C++11 code with illegal alignas specifier on x86_64-linux-gnu: unexpected expression ‘f’ of kind overload) /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 --- 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" }