This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C,C++] integer constants in attribute arguments
- From: Marc Glisse <marc dot glisse at inria dot fr>
- To: Andreas Schwab <schwab at suse dot de>
- Cc: Dominique Dhumieres <dominiq at lps dot ens dot fr>, gcc-patches at gcc dot gnu dot org
- Date: Wed, 5 Feb 2014 12:58:39 +0100 (CET)
- Subject: Re: [C,C++] integer constants in attribute arguments
- Authentication-results: sourceware.org; auth=none
- References: <20140205093343 dot 3DE85104 at mailhost dot lps dot ens dot fr> <alpine dot DEB dot 2 dot 10 dot 1402051036540 dot 3719 at laptop-mg dot saclay dot inria dot fr> <mvmeh3h7rim dot fsf at hawking dot suse dot de>
On Wed, 5 Feb 2014, Andreas Schwab wrote:
Marc Glisse <marc.glisse@inria.fr> writes:
On Wed, 5 Feb 2014, Dominique Dhumieres wrote:
I'll give it a day (it can easily be changed again later).
IMO it would be better (more general) to use a dg-require-effective-target
with the corresponding test(s) in target-supports-dg.exp.
But which tests? One for over/under alignment of functions, one for
init_priority, maybe yet one more, all that for a file that is just
checking that the parser understands the attribute argument is a
constant...
Wrt. the function decl it should probably just be changed to a variable
decl. Alignments on function decls are kind of exotic.
Good idea. How about this patch then?
--
Marc Glisse
Index: gcc/testsuite/g++.dg/cpp0x/constexpr-attribute2.C
===================================================================
--- gcc/testsuite/g++.dg/cpp0x/constexpr-attribute2.C (revision 207501)
+++ gcc/testsuite/g++.dg/cpp0x/constexpr-attribute2.C (working copy)
@@ -1,10 +1,11 @@
+// { dg-do compile { target init_priority } }
// { dg-options -std=gnu++11 }
struct t { t(); };
constexpr int prio = 123;
constexpr int size = 8;
constexpr int pos = 1;
enum A { zero = 0, one, two };
__attribute__((init_priority(prio))) t a;
@@ -22,11 +23,11 @@ enum E2 {
};
__attribute__((init_priority(E2_second))) t c;
void* my_calloc(unsigned, unsigned) __attribute__((alloc_size(pos,two)));
void* my_realloc(void*, unsigned) __attribute__((alloc_size(two)));
typedef char vec __attribute__((vector_size(size)));
void f(char*) __attribute__((nonnull(pos)));
-void g() __attribute__((aligned(size)));
+char g __attribute__((aligned(size)));