diff mbox series

Fix PR53037 failures on strict-alignment platforms

Message ID 2592316.MiMHRH4XUh@polaris
State New
Headers show
Series Fix PR53037 failures on strict-alignment platforms | expand

Commit Message

Eric Botcazou Nov. 7, 2017, 5:37 p.m. UTC
As discussed in the audit trail, testing TYPE_USER_ALIGN to find out whether 
there is an "aligned" attribute on the type is not robust since the layout 
machinery will clear it after internal alignment promotion, so the attached 
patchlet replaces it with an explicit lookup (that's as cheap in almost all 
cases since lookup_attribute is a macro with a shortcut for NULL_TREE).

Tested on SPARC64/Linux, applied on the mainline as obvious, this fixes:

FAIL: gcc.dg/pr53037-2.c  (test for warnings, line 16)
FAIL: gcc.dg/pr53037-2.c  (test for warnings, line 32)
FAIL: gcc.dg/pr53037-2.c  (test for warnings, line 8)
FAIL: gcc.dg/pr53037-3.c  (test for warnings, line 16)
FAIL: gcc.dg/pr53037-3.c  (test for warnings, line 32)
FAIL: gcc.dg/pr53037-3.c  (test for warnings, line 8)
FAIL: g++.dg/pr53037-2.C  -std=gnu++11  (test for warnings, line 16)
FAIL: g++.dg/pr53037-2.C  -std=gnu++11  (test for warnings, line 29)
FAIL: g++.dg/pr53037-2.C  -std=gnu++11  (test for warnings, line 6)
FAIL: g++.dg/pr53037-2.C  -std=gnu++14  (test for warnings, line 16)
FAIL: g++.dg/pr53037-2.C  -std=gnu++14  (test for warnings, line 29)
FAIL: g++.dg/pr53037-2.C  -std=gnu++14  (test for warnings, line 6)
FAIL: g++.dg/pr53037-2.C  -std=gnu++98  (test for warnings, line 16)
FAIL: g++.dg/pr53037-2.C  -std=gnu++98  (test for warnings, line 29)
FAIL: g++.dg/pr53037-2.C  -std=gnu++98  (test for warnings, line 6)
FAIL: g++.dg/pr53037-3.C  -std=gnu++11  (test for warnings, line 16)
FAIL: g++.dg/pr53037-3.C  -std=gnu++11  (test for warnings, line 29)
FAIL: g++.dg/pr53037-3.C  -std=gnu++11  (test for warnings, line 6)
FAIL: g++.dg/pr53037-3.C  -std=gnu++14  (test for warnings, line 16)
FAIL: g++.dg/pr53037-3.C  -std=gnu++14  (test for warnings, line 29)
FAIL: g++.dg/pr53037-3.C  -std=gnu++14  (test for warnings, line 6)
FAIL: g++.dg/pr53037-3.C  -std=gnu++98  (test for warnings, line 16)
FAIL: g++.dg/pr53037-3.C  -std=gnu++98  (test for warnings, line 29)
FAIL: g++.dg/pr53037-3.C  -std=gnu++98  (test for warnings, line 6)


2017-11-07  Eric Botcazou  <ebotcazou@adacore.com>

	PR c/53037
	* stor-layout.c: Include attribs.h.
	(handle_warn_if_not_align): Replace test on TYPE_USER_ALIGN with
	explicit lookup of "aligned" attribute.
diff mbox series

Patch

Index: stor-layout.c
===================================================================
--- stor-layout.c	(revision 254449)
+++ stor-layout.c	(working copy)
@@ -40,6 +40,7 @@  along with GCC; see the file COPYING3.
 #include "tree-inline.h"
 #include "dumpfile.h"
 #include "gimplify.h"
+#include "attribs.h"
 #include "debug.h"
 
 /* Data type for the expressions representing sizes of data types.
@@ -1106,7 +1107,7 @@  handle_warn_if_not_align (tree field, un
 
   if (!warn_if_not_align
       && warn_packed_not_aligned
-      && TYPE_USER_ALIGN (type))
+      && lookup_attribute ("aligned", TYPE_ATTRIBUTES (type)))
     {
       warn_if_not_align = TYPE_ALIGN (type);
       opt_w = OPT_Wpacked_not_aligned;