From: Giovanni Bajo Date: Sat, 16 Oct 2004 11:04:58 +0000 (+0000) Subject: re PR c++/10479 (alignof and sizeof (and other expressions) in attributes does not... X-Git-Tag: releases/gcc-4.0.0~3999 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1ed3dfd55da6cfa09a9395881e73405b37c83c8b;p=thirdparty%2Fgcc.git re PR c++/10479 (alignof and sizeof (and other expressions) in attributes does not compile inside template classes) PR c++/10479 * parser.c (cp_parser_parenthesized_expression_list): Fold non-dependent expressions in attribute lists. PR c++/10479 * g++.dg/ext/attrib16.C: New test. From-SVN: r89135 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 7fef9fbf666d..ebd8705f674c 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2004-10-16 Giovanni Bajo + + PR c++/10479 + * parser.c (cp_parser_parenthesized_expression_list): Fold + non-dependent expressions in attribute lists. + 2004-10-15 Mark Mitchell PR c++/17042 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 611a794d7665..76738262e7c1 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -4420,6 +4420,7 @@ cp_parser_parenthesized_expression_list (cp_parser* parser, bool *non_constant_p) { tree expression_list = NULL_TREE; + bool fold_expr_p = is_attribute_list; tree identifier = NULL_TREE; /* Assume all the expressions will be constant. */ @@ -4462,6 +4463,9 @@ cp_parser_parenthesized_expression_list (cp_parser* parser, else expr = cp_parser_assignment_expression (parser); + if (fold_expr_p) + expr = fold_non_dependent_expr (expr); + /* Add it to the list. We add error_mark_node expressions to the list, so that we can still tell if the correct form for a parenthesized expression-list diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a9ec7d76f5cf..0ca8452357fa 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2004-10-16 Giovanni Bajo + + PR c++/10479 + * g++.dg/ext/attrib16.C: New test. + 2004-10-15 Mark Mitchell PR c++/17042 diff --git a/gcc/testsuite/g++.dg/ext/attrib16.C b/gcc/testsuite/g++.dg/ext/attrib16.C new file mode 100644 index 000000000000..2e73fca70ba3 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/attrib16.C @@ -0,0 +1,8 @@ +// { dg-do compile } +// Origin: +// PR c++/10479: use of non dependent expressions in attributes in templates + +template +struct foo2 { + float bar __attribute__((aligned(__alignof__(double)))); +};