re PR c++/10479 (alignof and sizeof (and other expressions) in attributes does not...
authorGiovanni Bajo <giovannibajo@gcc.gnu.org>
Sat, 16 Oct 2004 11:04:58 +0000 (11:04 +0000)
committerGiovanni Bajo <giovannibajo@gcc.gnu.org>
Sat, 16 Oct 2004 11:04:58 +0000 (11:04 +0000)
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

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ext/attrib16.C [new file with mode: 0644]

index 7fef9fbf666d87ef4625aafbc9095c1855ae7244..ebd8705f674c09dbb429bb8d7c00315a2d4efc8c 100644 (file)
@@ -1,3 +1,9 @@
+2004-10-16  Giovanni Bajo  <giovannibajo@gcc.gnu.org>
+
+       PR c++/10479
+       * parser.c (cp_parser_parenthesized_expression_list): Fold
+       non-dependent expressions in attribute lists.
+
 2004-10-15  Mark Mitchell  <mark@codesourcery.com>
 
        PR c++/17042
index 611a794d7665ada54df8c844329a1aaf0b3566f4..76738262e7c16464563eba8803beee7945a72cea 100644 (file)
@@ -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
index a9ec7d76f5cfbe084cc006bb4f6a702fefadd6a4..0ca8452357faba113b6326af7f5a097f243cf0cb 100644 (file)
@@ -1,3 +1,8 @@
+2004-10-16  Giovanni Bajo  <giovannibajo@gcc.gnu.org>
+
+       PR c++/10479
+       * g++.dg/ext/attrib16.C: New test.
+
 2004-10-15  Mark Mitchell  <mark@codesourcery.com>
 
        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 (file)
index 0000000..2e73fca
--- /dev/null
@@ -0,0 +1,8 @@
+// { dg-do compile }
+// Origin: <rguenth at tat dot physik dot uni-tuebingen dot de>
+// PR c++/10479: use of non dependent expressions in attributes in templates
+
+template <int i>
+struct foo2 {
+  float bar __attribute__((aligned(__alignof__(double))));
+};