This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[C++0x patch] constexpr in attribute argument


Hi!

Checking the new constexpr support in the C++0x frontend, I've notices
that there is one place where a plain constant is accepted but a
constexpr is not.
Probably you have guessed (from the subject line above), it is in an
attribute argument, e.g:

constexpr int foo()
{
    return 4;
}
int __attribute__((aligned(4))) a; //ok
int __attribute__((aligned(foo()))) b; //error: requested alignment is
not a constant

IMHO, this code is correct.

The attached patch solves this issue cleanly, I think.
In the included testsuite I've used only the attribute ((aligned)),
but I don't think that should matter too much.

Regards
--
Rodrigo

Changelog:

gcc/cp/

2011-03-10  Rodrigo Rivas Costa  <rodrigorivascosta@gmail.com>

	* decl2.c (cp_check_const_attributes): New.
	(cplus_decl_attributes): Call cp_check_const_attributes.

gcc/testsuite/

2011-03-10  Rodrigo Rivas Costa  <rodrigorivascosta@gmail.com>

       * g++.dg/cpp0x/constexpr-attribute.C: New.

Attachment: const-attr.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]