diff mbox series

[c-family] Issue a warning in C++ on pragma scalar_storage_order

Message ID 14071962.Srb1NyX0Vs@polaris
State New
Headers show
Series [c-family] Issue a warning in C++ on pragma scalar_storage_order | expand

Commit Message

Eric Botcazou Sept. 15, 2017, 11:07 a.m. UTC
Hi,

this plugs the hole reported by Florian on the gcc@ list, namely that no 
warning is issued with -Wall in C++ on pragma scalar_storage_order.

Tested on x86_64-suse-linux, OK for the mainline?  And some branches?


2017-09-15  Eric Botcazou  <ebotcazou@adacore.com>

	* 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  Eric Botcazou  <ebotcazou@adacore.com>

	* g++.dg/sso-1.C: New test.
	* g++.dg/sso-2.C: Likewise.

Comments

Jeff Law Sept. 15, 2017, 4:11 p.m. UTC | #1
On 09/15/2017 05:07 AM, Eric Botcazou wrote:
> Hi,
> 
> this plugs the hole reported by Florian on the gcc@ list, namely that no 
> warning is issued with -Wall in C++ on pragma scalar_storage_order.
> 
> Tested on x86_64-suse-linux, OK for the mainline?  And some branches?
> 
> 
> 2017-09-15  Eric Botcazou  <ebotcazou@adacore.com>
> 
> 	* 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  Eric Botcazou  <ebotcazou@adacore.com>
> 
> 	* g++.dg/sso-1.C: New test.
> 	* g++.dg/sso-2.C: Likewise.
> 
OK.
jeff
diff mbox series

Patch

Index: c-family/c-pragma.c
===================================================================
--- c-family/c-pragma.c	(revision 252749)
+++ c-family/c-pragma.c	(working copy)
@@ -415,7 +415,19 @@  handle_pragma_scalar_storage_order (cpp_
   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)