From a372ea889b3491192d80439ad3bf45fa10ce759b Mon Sep 17 00:00:00 2001 From: ebotcazou Date: Fri, 15 Sep 2017 17:11:47 +0000 Subject: [PATCH] * c-pragma.c (handle_pragma_scalar_storage_order): Expand on error message for non-uniform endianness and issue a warning in C++. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@252831 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/c-family/ChangeLog | 5 +++++ gcc/c-family/c-pragma.c | 14 +++++++++++++- gcc/testsuite/ChangeLog | 7 ++++++- gcc/testsuite/g++.dg/sso-1.C | 8 ++++++++ gcc/testsuite/g++.dg/sso-2.C | 6 ++++++ 5 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/sso-1.C create mode 100644 gcc/testsuite/g++.dg/sso-2.C diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 4fffa315644..a3f990d49fd 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,8 @@ +2017-09-15 Eric Botcazou + + * c-pragma.c (handle_pragma_scalar_storage_order): Expand on error + message for non-uniform endianness and issue a warning in C++. + 2017-09-15 Jakub Jelinek * c.opt (Wc++1z-compat): Change from option to undocumented alias. diff --git a/gcc/c-family/c-pragma.c b/gcc/c-family/c-pragma.c index a2ffdbacbbb..f7b59b34807 100644 --- a/gcc/c-family/c-pragma.c +++ b/gcc/c-family/c-pragma.c @@ -415,7 +415,19 @@ handle_pragma_scalar_storage_order (cpp_reader *ARG_UNUSED(dummy)) tree x; if (BYTES_BIG_ENDIAN != WORDS_BIG_ENDIAN) - error ("scalar_storage_order is not supported"); + { + error ("scalar_storage_order is not supported because endianness " + "is not uniform"); + return; + } + + if (c_dialect_cxx ()) + { + if (warn_unknown_pragmas > in_system_header_at (input_location)) + warning (OPT_Wunknown_pragmas, + "%<#pragma scalar_storage_order%> is not supported for C++"); + return; + } token = pragma_lex (&x); if (token != CPP_NAME) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index bdc79b61e04..303f700c451 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,4 +1,9 @@ -2017-09-13 Paolo Carlini +2017-09-15 Eric Botcazou + + * g++.dg/sso-1.C: New test. + * g++.dg/sso-2.C: Likewise. + +2017-09-15 Paolo Carlini PR c++/78648 * g++.dg/cpp0x/lambda/lambda-ice21.C: New. diff --git a/gcc/testsuite/g++.dg/sso-1.C b/gcc/testsuite/g++.dg/sso-1.C new file mode 100644 index 00000000000..0f59d0c4069 --- /dev/null +++ b/gcc/testsuite/g++.dg/sso-1.C @@ -0,0 +1,8 @@ +/* Test support of scalar_storage_order attribute */ + +/* { dg-do compile } */ + +struct __attribute__((scalar_storage_order("little-endian"))) Rec /* { dg-warning "attribute ignored" } */ +{ + int i; +}; diff --git a/gcc/testsuite/g++.dg/sso-2.C b/gcc/testsuite/g++.dg/sso-2.C new file mode 100644 index 00000000000..402a61e3b47 --- /dev/null +++ b/gcc/testsuite/g++.dg/sso-2.C @@ -0,0 +1,6 @@ +/* Test support of scalar_storage_order pragma */ + +/* { dg-do compile } */ +/* { dg-options "-Wall" } */ + +#pragma scalar_storage_order little-endian /* { dg-warning "not supported" } */ -- 2.11.4.GIT