+2010-12-22 Rodrigo Rivas Costa <rodrigorivascosta@gmail.com>
+
+ * parser.c (cp_parser_unary_expression): Call pedwarn for alignof
+ with expression.
+
2010-12-18 Nicola Pero <nicola.pero@meta-innovation.com>
* parser.c (cp_parser_objc_try_catch_finally_statement): Call
unary-operator cast-expression
sizeof unary-expression
sizeof ( type-id )
+ alignof ( type-id ) [C++0x]
new-expression
delete-expression
__extension__ cast-expression
__alignof__ unary-expression
__alignof__ ( type-id )
+ alignof unary-expression [C++0x]
__real__ cast-expression
__imag__ cast-expression
&& identifier
if (TYPE_P (operand))
return cxx_sizeof_or_alignof_type (operand, op, true);
else
- return cxx_sizeof_or_alignof_expr (operand, op, true);
+ {
+ /* ISO C++ defines alignof only with types, not with
+ expressions. So pedwarn if alignof is used with a non-
+ type expression. However, __alignof__ is ok. */
+ if (cxx_dialect >= cxx0x
+ && !strcmp (IDENTIFIER_POINTER (token->u.value),
+ "alignof"))
+ pedwarn (token->location, OPT_pedantic,
+ "ISO C++ does not allow %<alignof%> "
+ "with a non-type");
+
+ return cxx_sizeof_or_alignof_expr (operand, op, true);
+ }
}
case RID_NEW:
+2010-12-22 Rodrigo Rivas Costa <rodrigorivascosta@gmail.com>
+
+ * g++.dg/cpp0x/alignof2.C: New.
+
2010-12-22 Martin Jambor <mjambor@suse.cz>
PR tree-optimization/45934
--- /dev/null
+// { dg-do compile }
+// { dg-options "-std=c++0x -pedantic" }
+int main(void)
+{
+ alignof(int); //ok with a type but not with an expression
+ alignof(3); // { dg-warning "alignof" }
+}