forked from wangliu-iscas/gcc-patch
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add scalar_storage_order support to C++
This patch adds support scalar_storage_order attribute to C++ front-end. It treats the opposite order fields similar as the packed fields are treated such that they will not bind to references. For arrays, the attributes applies to the inner type rather than the array type similar. The code is similar to how it is handled in the C front-end. 2021-04-03 Andrew Pinski <apinski@marvell.com> Co-authored-by: Naveen H S <naveenh@marvell.com> gcc/ChangeLog: * c-family/c-attribs.cc (handle_scalar_storage_order_attribute): Do not reject the C++ cases. * cp/class.cc (layout_nonempty_base_or_field): Fix the type of arrays in C++. * cp/call.cc (reference_binding): Treat reversed field similar as packed fields. (build_temp): Likewise. (convert_like_internal): Emit error code for non binding reversed endian field. * cp/cp-tree.h (clk_implicit_rval) : Add clk_reversed. * cp/cp-tree.c (lvalue_kind) : Handle reverse storage ordered operands. gcc/testsuite/ChangeLog: * c-c++-common/sso/dump.h: Move from gcc.dg/sso to c-c++-common/sso. * c-c++-common/sso/init1.h: Likewise. * c-c++-common/sso/init13.h: Likewise. * c-c++-common/sso/init2.h: Likewise. * c-c++-common/sso/init3.h: Likewise. * c-c++-common/sso/init4.h: Likewise. * c-c++-common/sso/init5.h: Likewise. * c-c++-common/sso/init6.h: Likewise. * c-c++-common/sso/init7.h: Likewise. * c-c++-common/sso/init8.h: Likewise. * c-c++-common/sso/init9.h: Likewise. * c-c++-common/sso/p1.c: Likewise. * c-c++-common/sso/p13.c: Likewise. * c-c++-common/sso/p2.c: Likewise. * c-c++-common/sso/p3.c: Likewise. * c-c++-common/sso/p4.c: Likewise. * c-c++-common/sso/p5.c: Likewise. * c-c++-common/sso/p6.c: Likewise. * c-c++-common/sso/p7.c: Likewise. * c-c++-common/sso/p8.c: Likewise. * c-c++-common/sso/p9.c: Likewise. * c-c++-common/sso/q1.c: Likewise. * c-c++-common/sso/q13.c: Likewise. * c-c++-common/sso/q2.c: Likewise. * c-c++-common/sso/q3.c: Likewise. * c-c++-common/sso/q4.c: Likewise. * c-c++-common/sso/q5.c: Likewise. * c-c++-common/sso/q6.c: Likewise. * c-c++-common/sso/q7.c: Likewise. * c-c++-common/sso/q8.c: Likewise. * c-c++-common/sso/q9.c: Likewise. * c-c++-common/sso/r3.c: Likewise. * c-c++-common/sso/r5.c: Likewise. * c-c++-common/sso/r6.c: Likewise. * c-c++-common/sso/r7.c: Likewise. * c-c++-common/sso/r8.c: Likewise. * c-c++-common/sso/s3.c: Likewise. * c-c++-common/sso/s5.c: Likewise. * c-c++-common/sso/s6.c: Likewise. * c-c++-common/sso/s7.c: Likewise. * c-c++-common/sso/s8.c: Likewise. * c-c++-common/sso/t1.c: Likewise. * c-c++-common/sso/t13.c: Likewise. * c-c++-common/sso/t2.c: Likewise. * c-c++-common/sso/t3.c: Likewise. * c-c++-common/sso/t4.c: Likewise. * c-c++-common/sso/t5.c: Likewise. * c-c++-common/sso/t6.c: Likewise. * c-c++-common/sso/t7.c: Likewise. * c-c++-common/sso/t8.c: Likewise. * c-c++-common/sso/t9.c: Likewise. * c-c++-common/sso/u5.c: Likewise. * c-c++-common/sso/t6.c: Likewise. * g++.dg/sso/sso.exp: New file. * g++.dg/sso/auto-1.C: New file. * g++.dg/sso/auto-2.C: New file. * g++.dg/sso/auto-3.C: New file. * g++.dg/sso/template-reference-1.C: New file. * g++.dg/sso/template-reference-2.C: New file. * g++.dg/sso/template-reference-3.C: New file. * g++.dg/sso/template-reference-4.C: New file. * g++.dg/sso-1.C: Modified.
- Loading branch information
1 parent
c2d62cd
commit 6e4643b
Showing
68 changed files
with
220 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions
1
gcc/testsuite/gcc.dg/sso/p13.c → gcc/testsuite/c-c++-common/sso/p13.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
/* { dg-do run } */ | ||
/* { dg-additional-options "-fext-numeric-literals" { target c++ } } */ | ||
|
||
#include <stdio.h> | ||
|
||
|
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions
1
gcc/testsuite/gcc.dg/sso/q13.c → gcc/testsuite/c-c++-common/sso/q13.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
/* { dg-do run } */ | ||
/* { dg-additional-options "-fext-numeric-literals" { target c++ } } */ | ||
|
||
#include <stdio.h> | ||
|
||
|
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions
1
gcc/testsuite/gcc.dg/sso/t13.c → gcc/testsuite/c-c++-common/sso/t13.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
/* { dg-do run } */ | ||
/* { dg-additional-options "-fext-numeric-literals" { target c++ } } */ | ||
|
||
#include <stdio.h> | ||
|
||
|
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* { dg-do compile { target c++11 } } */ | ||
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ | ||
struct __attribute__((scalar_storage_order("big-endian"))) Rec | ||
{ | ||
int p; | ||
}; | ||
#else | ||
struct __attribute__((scalar_storage_order("little-endian"))) Rec | ||
{ | ||
int p; | ||
}; | ||
#endif | ||
|
||
void f(Rec *a) | ||
{ | ||
auto t = a->p; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* { dg-do compile { target c++14 } } */ | ||
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ | ||
struct __attribute__((scalar_storage_order("big-endian"))) Rec | ||
{ | ||
int p; | ||
}; | ||
#else | ||
struct __attribute__((scalar_storage_order("little-endian"))) Rec | ||
{ | ||
int p; | ||
}; | ||
#endif | ||
|
||
decltype(auto) f(Rec *a) | ||
{ | ||
return a->p; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* { dg-do compile { target c++14 } } */ | ||
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ | ||
struct __attribute__((scalar_storage_order("big-endian"))) Rec | ||
{ | ||
int p; | ||
}; | ||
#else | ||
struct __attribute__((scalar_storage_order("little-endian"))) Rec | ||
{ | ||
int p; | ||
}; | ||
#endif | ||
|
||
decltype(auto) f(Rec *a) | ||
{ | ||
return (a->p); /* { dg-error "" } */ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Copyright (C) 2013-2017 Free Software Foundation, Inc. | ||
|
||
# This program is free software; you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation; either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with GCC; see the file COPYING3. If not see | ||
# <http://www.gnu.org/licenses/>. | ||
|
||
# Load support procs. | ||
load_lib g++-dg.exp | ||
load_lib torture-options.exp | ||
|
||
if { ![check_effective_target_int32] } { | ||
return | ||
} | ||
|
||
# Initialize `dg'. | ||
torture-init | ||
dg-init | ||
|
||
set SSO_TORTURE_OPTIONS [list \ | ||
{ -O0 } \ | ||
{ -O1 -fno-inline } \ | ||
{ -O2 } \ | ||
{ -O3 -finline-functions } \ | ||
{ -Os } \ | ||
{ -Og -g } ] | ||
|
||
set-torture-options $SSO_TORTURE_OPTIONS | ||
|
||
# Main loop. | ||
g++-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.C $srcdir/c-c++-common/sso/*.c ]] "" "" | ||
|
||
# All done. | ||
dg-finish | ||
torture-finish |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* { dg-do compile } */ | ||
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ | ||
struct __attribute__((scalar_storage_order("big-endian"))) Rec | ||
{ | ||
int p; | ||
}; | ||
#else | ||
struct __attribute__((scalar_storage_order("little-endian"))) Rec | ||
{ | ||
int p; | ||
}; | ||
#endif | ||
template <typename T> void g(const T &); | ||
|
||
|
||
void f(Rec *a) | ||
{ | ||
g(a->p); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* { dg-do compile } */ | ||
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ | ||
struct __attribute__((scalar_storage_order("big-endian"))) Rec | ||
{ | ||
int p; | ||
}; | ||
#else | ||
struct __attribute__((scalar_storage_order("little-endian"))) Rec | ||
{ | ||
int p; | ||
}; | ||
#endif | ||
template <typename T> void g(T &); | ||
|
||
|
||
void f(Rec *a) | ||
{ | ||
g(a->p); /* { dg-error "" } */ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* { dg-do compile { target c++11 } } */ | ||
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ | ||
struct __attribute__((scalar_storage_order("big-endian"))) Rec | ||
{ | ||
int p; | ||
}; | ||
#else | ||
struct __attribute__((scalar_storage_order("little-endian"))) Rec | ||
{ | ||
int p; | ||
}; | ||
#endif | ||
template <typename T> void g(T &&); | ||
|
||
|
||
void f(Rec *a) | ||
{ | ||
g(a->p); /* { dg-error "" } */ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* { dg-do compile } */ | ||
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ | ||
struct __attribute__((scalar_storage_order("big-endian"))) Rec | ||
{ | ||
int p; | ||
}; | ||
#else | ||
struct __attribute__((scalar_storage_order("little-endian"))) Rec | ||
{ | ||
int p; | ||
}; | ||
#endif | ||
template <typename T> void g(T &); | ||
|
||
|
||
void f(Rec *a) | ||
{ | ||
g( (a->p)); /* { dg-error "" } */ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters