This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Two tiny diagnostics fixes (PR c/35440, c++/35332)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Gabriel Dos Reis <gdr at integrable-solutions dot net>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Wed, 19 Mar 2008 15:45:48 -0400
- Subject: [PATCH] Two tiny diagnostics fixes (PR c/35440, c++/35332)
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
These are 2 unrelated changes, but are so small I'm putting them into
one patch. The c-pretty-print.c fix is for CONSTRUCTOR with
RECORD_TYPE/UNION_TYPE/ARRAY_TYPE, which wasn't handled at all.
The C++ fix just forwards dump_expr of the unordered etc. expressions
to pp_expression which already handles them properly (in c-pretty-print.c).
Regtested on x86_64-linux, ok for trunk/4.3?
2008-03-19 Jakub Jelinek <jakub@redhat.com>
PR c/35440
* c-pretty-print.c (pp_c_initializer_list): Handle CONSTRUCTOR
for all types.
PR c++/35332
* error.c (dump_expr): Pass {,UN}ORDERED_EXPR, UN{LT,LE,GT,GE,EQ}_EXPR
and LTGT_EXPR to pp_expression.
* gcc.dg/pr35440.c: New test.
* g++.dg/other/error27.C: New test.
--- gcc/c-pretty-print.c.jj 2008-02-11 14:48:12.000000000 +0100
+++ gcc/c-pretty-print.c 2008-03-19 14:50:09.000000000 +0100
@@ -1173,6 +1173,12 @@ pp_c_initializer_list (c_pretty_printer
tree type = TREE_TYPE (e);
const enum tree_code code = TREE_CODE (type);
+ if (TREE_CODE (e) == CONSTRUCTOR)
+ {
+ pp_c_constructor_elts (pp, CONSTRUCTOR_ELTS (e));
+ return;
+ }
+
switch (code)
{
case RECORD_TYPE:
@@ -1207,16 +1213,12 @@ pp_c_initializer_list (c_pretty_printer
case VECTOR_TYPE:
if (TREE_CODE (e) == VECTOR_CST)
pp_c_expression_list (pp, TREE_VECTOR_CST_ELTS (e));
- else if (TREE_CODE (e) == CONSTRUCTOR)
- pp_c_constructor_elts (pp, CONSTRUCTOR_ELTS (e));
else
break;
return;
case COMPLEX_TYPE:
- if (TREE_CODE (e) == CONSTRUCTOR)
- pp_c_constructor_elts (pp, CONSTRUCTOR_ELTS (e));
- else if (TREE_CODE (e) == COMPLEX_CST || TREE_CODE (e) == COMPLEX_EXPR)
+ if (TREE_CODE (e) == COMPLEX_CST || TREE_CODE (e) == COMPLEX_EXPR)
{
const bool cst = TREE_CODE (e) == COMPLEX_CST;
pp_expression (pp, cst ? TREE_REALPART (e) : TREE_OPERAND (e, 0));
--- gcc/cp/error.c.jj 2008-03-02 23:32:01.000000000 +0100
+++ gcc/cp/error.c 2008-03-19 15:32:28.000000000 +0100
@@ -2048,6 +2048,14 @@ dump_expr (tree t, int flags)
case CONJ_EXPR:
case VECTOR_CST:
case FIXED_CST:
+ case UNORDERED_EXPR:
+ case ORDERED_EXPR:
+ case UNLT_EXPR:
+ case UNLE_EXPR:
+ case UNGT_EXPR:
+ case UNGE_EXPR:
+ case UNEQ_EXPR:
+ case LTGT_EXPR:
pp_expression (cxx_pp, t);
break;
--- gcc/testsuite/gcc.dg/pr35440.c.jj 2008-03-19 15:57:13.000000000 +0100
+++ gcc/testsuite/gcc.dg/pr35440.c 2008-03-19 15:47:35.000000000 +0100
@@ -0,0 +1,12 @@
+/* PR c/35440 */
+/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
+
+struct A {};
+struct B { int i; char j[2]; };
+
+void foo (void)
+{
+ (struct A){}(); /* { dg-error "called object" } */
+ (struct B){ .i = 2, .j[1] = 1 }(); /* { dg-error "called object" } */
+}
--- gcc/testsuite/g++.dg/other/error27.C.jj 2008-03-19 15:35:05.000000000 +0100
+++ gcc/testsuite/g++.dg/other/error27.C 2008-03-19 15:42:17.000000000 +0100
@@ -0,0 +1,12 @@
+// PR c++/35332
+// { dg-do compile }
+
+void foo (double x, double y)
+{
+ __builtin_isgreater(x, y)(); // { dg-error "__builtin_\[^\n\]*cannot be used as a function" }
+ __builtin_isless(x, y)(); // { dg-error "__builtin_\[^\n\]*cannot be used as a function" }
+ __builtin_isgreaterequal(x, y)(); // { dg-error "__builtin_\[^\n\]*cannot be used as a function" }
+ __builtin_islessequal(x, y)(); // { dg-error "__builtin_\[^\n\]*cannot be used as a function" }
+ __builtin_isunordered(x, y)(); // { dg-error "__builtin_\[^\n\]*cannot be used as a function" }
+ __builtin_islessgreater(x, y)(); // { dg-error "__builtin_\[^\n\]*cannot be used as a function" }
+}
Jakub