This commit is contained in:
Jakub Jelinek 2007-10-16 14:18:55 +00:00
parent 6a8aa58890
commit 70a3a1d063
10 changed files with 1297 additions and 1 deletions

132
gcc41-pr32121.patch Normal file
View File

@ -0,0 +1,132 @@
2007-10-12 Jakub Jelinek <jakub@redhat.com>
PR c++/32121
* parser.c (cp_parser_compound_statement): Handle label-declarations
at the beginning of the compound statement.
(cp_parser_block_declaration): Issue diagnostics about __label__
not at the beginning of a block.
* g++.dg/ext/label4.C: Adjust error regexp.
* g++.dg/ext/label7.C: New test.
* g++.dg/ext/label8.C: New test.
* g++.dg/ext/label9.C: New test.
--- gcc/cp/parser.c (revision 129252)
+++ gcc/cp/parser.c (revision 129253)
@@ -6821,6 +6821,15 @@ cp_parser_expression_statement (cp_parse
compound-statement:
{ statement-seq [opt] }
+ GNU extension:
+
+ compound-statement:
+ { label-declaration-seq [opt] statement-seq [opt] }
+
+ label-declaration-seq:
+ label-declaration
+ label-declaration-seq label-declaration
+
Returns a tree representing the statement. */
static tree
@@ -6834,6 +6843,9 @@ cp_parser_compound_statement (cp_parser
return error_mark_node;
/* Begin the compound-statement. */
compound_stmt = begin_compound_stmt (in_try ? BCS_TRY_BLOCK : 0);
+ /* If the next keyword is `__label__' we have a label declaration. */
+ while (cp_lexer_next_token_is_keyword (parser->lexer, RID_LABEL))
+ cp_parser_label_declaration (parser);
/* Parse an (optional) statement-seq. */
cp_parser_statement_seq_opt (parser, in_statement_expr);
/* Finish the compound-statement. */
@@ -7711,7 +7723,6 @@ cp_parser_declaration (cp_parser* parser
block-declaration:
__extension__ block-declaration
- label-declaration
C++0x Extension:
@@ -7772,12 +7783,16 @@ cp_parser_block_declaration (cp_parser *
cp_parser_using_declaration (parser,
/*access_declaration_p=*/false);
}
- /* If the next keyword is `__label__' we have a label declaration. */
+ /* If the next keyword is `__label__' we have a misplaced label
+ declaration. */
else if (token1->keyword == RID_LABEL)
{
- if (statement_p)
- cp_parser_commit_to_tentative_parse (parser);
- cp_parser_label_declaration (parser);
+ cp_lexer_consume_token (parser->lexer);
+ error ("%<__label__%> not at the beginning of a block");
+ cp_parser_skip_to_end_of_statement (parser);
+ /* If the next token is now a `;', consume it. */
+ if (cp_lexer_next_token_is (parser->lexer, CPP_SEMICOLON))
+ cp_lexer_consume_token (parser->lexer);
}
/* If the next token is `static_assert' we have a static assertion. */
else if (token1->keyword == RID_STATIC_ASSERT)
--- gcc/testsuite/g++.dg/ext/label9.C (revision 0)
+++ gcc/testsuite/g++.dg/ext/label9.C (revision 129253)
@@ -0,0 +1,10 @@
+// PR c++/32121
+// { dg-do compile }
+
+int f (void)
+{
+ while (1)
+ __label__ a; // { dg-error "not at the beginning" }
+ for (;;)
+ __label__ b; // { dg-error "not at the beginning" }
+}
--- gcc/testsuite/g++.dg/ext/label4.C (revision 129252)
+++ gcc/testsuite/g++.dg/ext/label4.C (revision 129253)
@@ -3,4 +3,4 @@
// { dg-do compile }
-__label__ *l; // { dg-error "before" }
+__label__ *l; // { dg-error "not at the beginning of" }
--- gcc/testsuite/g++.dg/ext/label7.C (revision 0)
+++ gcc/testsuite/g++.dg/ext/label7.C (revision 129253)
@@ -0,0 +1,12 @@
+// PR c++/32121
+// { dg-do compile }
+
+int f (void)
+{
+ a:;
+ __label__ a; // { dg-error "not at the beginning" }
+ int b;
+ __label__ c; // { dg-error "not at the beginning" }
+ a:; // { dg-error "duplicate label" }
+ c:;
+}
--- gcc/testsuite/g++.dg/ext/label8.C (revision 0)
+++ gcc/testsuite/g++.dg/ext/label8.C (revision 129253)
@@ -0,0 +1,22 @@
+// PR c++/32121
+// { dg-do compile }
+
+int f (void)
+{
+ __label__ a, b;
+ __label__ c;
+ a:;
+ b:;
+ c:;
+ {
+ __label__ d;
+ d:;
+ if (0)
+ {
+ __label__ e;
+ __label__ f;
+ f:;
+ e:;
+ }
+ }
+}

230
gcc41-pr33136.patch Normal file
View File

@ -0,0 +1,230 @@
2007-10-15 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/33136
* opts.c (decode_options): Don't enable flag_ipa_type_escape.
* gcc.c-torture/execute/20070824-1.c: New test.
* gcc.dg/pr33136-1.c: New test.
* gcc.dg/pr33136-2.c: New test.
* gcc.dg/pr33136-3.c: New test.
--- gcc/opts.c (revision 129365)
+++ gcc/opts.c (revision 129366)
@@ -473,7 +473,6 @@ decode_options (unsigned int argc, const
flag_cse_skip_blocks = 1;
flag_gcse = 1;
flag_expensive_optimizations = 1;
- flag_ipa_type_escape = 1;
flag_strength_reduce = 1;
flag_rerun_cse_after_loop = 1;
flag_rerun_loop_opt = 1;
--- gcc/testsuite/gcc.c-torture/execute/20070824-1.c (revision 0)
+++ gcc/testsuite/gcc.c-torture/execute/20070824-1.c (revision 129366)
@@ -0,0 +1,24 @@
+/* PR tree-optimization/33136 */
+
+extern void abort (void);
+
+struct S
+{
+ struct S *a;
+ int b;
+};
+
+int
+main (void)
+{
+ struct S *s = (struct S *) 0, **p, *n;
+ for (p = &s; *p; p = &(*p)->a);
+ n = (struct S *) __builtin_alloca (sizeof (*n));
+ n->a = *p;
+ n->b = 1;
+ *p = n;
+
+ if (!s)
+ abort ();
+ return 0;
+}
--- gcc/testsuite/gcc.dg/pr33136-1.c (revision 0)
+++ gcc/testsuite/gcc.dg/pr33136-1.c (revision 129366)
@@ -0,0 +1,54 @@
+/* PR tree-optimization/33136 */
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+extern void abort (void);
+
+struct S
+{
+ struct S *a;
+ int b;
+ float f;
+};
+
+static struct S s;
+
+static int *
+__attribute__((noinline, const))
+foo (void)
+{
+ return &s.b;
+}
+
+float
+__attribute__((noinline))
+bar (float *f)
+{
+ s.f = 1.0;
+ *f = 4.0;
+ return s.f;
+}
+
+int
+__attribute__((noinline))
+baz (int *x)
+{
+ s.b = 1;
+ *x = 4;
+ return s.b;
+}
+
+int
+t (void)
+{
+ float f = 8.0;
+ return bar (&f) + baz (foo ());
+}
+
+int
+main (void)
+{
+ if (t () != 5)
+ abort ();
+ return 0;
+}
--- gcc/testsuite/gcc.dg/pr33136-3.c (revision 0)
+++ gcc/testsuite/gcc.dg/pr33136-3.c (revision 129366)
@@ -0,0 +1,60 @@
+/* PR tree-optimization/33136 */
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+extern void abort (void);
+
+struct S
+{
+ void *a;
+ int b[3];
+ double *c;
+};
+static double d, e;
+
+static struct S s;
+
+static int *
+__attribute__((noinline, const))
+foo (void)
+{
+ return (int *) &s.b;
+}
+
+double *
+__attribute__((noinline))
+bar (double **f)
+{
+ s.c = &d;
+ *f = &e;
+ /* As nothing ever takes the address of any double * field in struct S,
+ the write to *f can't alias with the s.c field. */
+ return s.c;
+}
+
+int
+__attribute__((noinline))
+baz (int *x)
+{
+ s.b[0] = 1;
+ *x = 4;
+ /* Function foo takes address of an int array field in struct S,
+ so *x can alias with the s.b field (and it does in this testcase). */
+ return s.b[0];
+}
+
+int
+__attribute__((noinline))
+t (void)
+{
+ double *f = (double *) 0;
+ return 10 * (bar (&f) != &d) + baz (foo ());
+}
+
+int
+main (void)
+{
+ if (t () != 4)
+ abort ();
+ return 0;
+}
--- gcc/testsuite/gcc.dg/pr33136-2.c (revision 0)
+++ gcc/testsuite/gcc.dg/pr33136-2.c (revision 129366)
@@ -0,0 +1,60 @@
+/* PR tree-optimization/33136 */
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+extern void abort (void);
+
+struct S
+{
+ void *a;
+ int b;
+ int *c;
+};
+static int d, e;
+
+static struct S s;
+
+static int *
+__attribute__((noinline, const))
+foo (void)
+{
+ return &s.b;
+}
+
+int *
+__attribute__((noinline))
+bar (int **f)
+{
+ s.c = &d;
+ *f = &e;
+ /* As nothing ever takes the address of any int * field in struct S,
+ the write to *f can't alias with the s.c field. */
+ return s.c;
+}
+
+int
+__attribute__((noinline))
+baz (int *x)
+{
+ s.b = 1;
+ *x = 4;
+ /* Function foo takes address of an int field in struct S,
+ so *x can alias with the s.b field (and it does in this testcase). */
+ return s.b;
+}
+
+int
+__attribute__((noinline))
+t (void)
+{
+ int *f = (int *) 0;
+ return 10 * (bar (&f) != &d) + baz (foo ());
+}
+
+int
+main (void)
+{
+ if (t () != 4)
+ abort ();
+ return 0;
+}

194
gcc41-pr33238.patch Normal file
View File

@ -0,0 +1,194 @@
2007-09-20 Jakub Jelinek <jakub@redhat.com>
PR c/33238
PR c/27301
* gimplify.c (gimplify_vla_decl): New function.
(gimplify_decl_expr): Move VLA decl handling to gimplify_vla_decl.
Call it.
(gimplify_target_expr): Handle variable length TARGET_EXPRs.
* gcc.c-torture/execute/20070919-1.c: New test.
* gcc.dg/pr33238.c: New test.
* gcc.dg/pr27301.c: New test.
--- gcc/gimplify.c (revision 128628)
+++ gcc/gimplify.c (revision 128629)
@@ -1144,6 +1144,42 @@ gimplify_return_expr (tree stmt, tree *p
return GS_ALL_DONE;
}
+static void
+gimplify_vla_decl (tree decl, tree *stmt_p)
+{
+ /* This is a variable-sized decl. Simplify its size and mark it
+ for deferred expansion. Note that mudflap depends on the format
+ of the emitted code: see mx_register_decls(). */
+ tree t, args, addr, ptr_type;
+
+ gimplify_one_sizepos (&DECL_SIZE (decl), stmt_p);
+ gimplify_one_sizepos (&DECL_SIZE_UNIT (decl), stmt_p);
+
+ /* All occurrences of this decl in final gimplified code will be
+ replaced by indirection. Setting DECL_VALUE_EXPR does two
+ things: First, it lets the rest of the gimplifier know what
+ replacement to use. Second, it lets the debug info know
+ where to find the value. */
+ ptr_type = build_pointer_type (TREE_TYPE (decl));
+ addr = create_tmp_var (ptr_type, get_name (decl));
+ DECL_IGNORED_P (addr) = 0;
+ t = build_fold_indirect_ref (addr);
+ SET_DECL_VALUE_EXPR (decl, t);
+ DECL_HAS_VALUE_EXPR_P (decl) = 1;
+
+ args = tree_cons (NULL, DECL_SIZE_UNIT (decl), NULL);
+ t = built_in_decls[BUILT_IN_ALLOCA];
+ t = build_function_call_expr (t, args);
+ t = fold_convert (ptr_type, t);
+ t = build2 (MODIFY_EXPR, void_type_node, addr, t);
+
+ gimplify_and_add (t, stmt_p);
+
+ /* Indicate that we need to restore the stack level when the
+ enclosing BIND_EXPR is exited. */
+ gimplify_ctxp->save_stack = true;
+}
+
/* Gimplifies a DECL_EXPR node *STMT_P by making any necessary allocation
and initialization explicit. */
@@ -1168,39 +1204,7 @@ gimplify_decl_expr (tree *stmt_p)
tree init = DECL_INITIAL (decl);
if (TREE_CODE (DECL_SIZE (decl)) != INTEGER_CST)
- {
- /* This is a variable-sized decl. Simplify its size and mark it
- for deferred expansion. Note that mudflap depends on the format
- of the emitted code: see mx_register_decls(). */
- tree t, args, addr, ptr_type;
-
- gimplify_one_sizepos (&DECL_SIZE (decl), stmt_p);
- gimplify_one_sizepos (&DECL_SIZE_UNIT (decl), stmt_p);
-
- /* All occurrences of this decl in final gimplified code will be
- replaced by indirection. Setting DECL_VALUE_EXPR does two
- things: First, it lets the rest of the gimplifier know what
- replacement to use. Second, it lets the debug info know
- where to find the value. */
- ptr_type = build_pointer_type (TREE_TYPE (decl));
- addr = create_tmp_var (ptr_type, get_name (decl));
- DECL_IGNORED_P (addr) = 0;
- t = build_fold_indirect_ref (addr);
- SET_DECL_VALUE_EXPR (decl, t);
- DECL_HAS_VALUE_EXPR_P (decl) = 1;
-
- args = tree_cons (NULL, DECL_SIZE_UNIT (decl), NULL);
- t = built_in_decls[BUILT_IN_ALLOCA];
- t = build_function_call_expr (t, args);
- t = fold_convert (ptr_type, t);
- t = build2 (MODIFY_EXPR, void_type_node, addr, t);
-
- gimplify_and_add (t, stmt_p);
-
- /* Indicate that we need to restore the stack level when the
- enclosing BIND_EXPR is exited. */
- gimplify_ctxp->save_stack = true;
- }
+ gimplify_vla_decl (decl, stmt_p);
if (init && init != error_mark_node)
{
@@ -4146,8 +4150,15 @@ gimplify_target_expr (tree *expr_p, tree
if (init)
{
/* TARGET_EXPR temps aren't part of the enclosing block, so add it
- to the temps list. */
- gimple_add_tmp_var (temp);
+ to the temps list. Handle also variable length TARGET_EXPRs. */
+ if (TREE_CODE (DECL_SIZE (temp)) != INTEGER_CST)
+ {
+ if (!TYPE_SIZES_GIMPLIFIED (TREE_TYPE (temp)))
+ gimplify_type_sizes (TREE_TYPE (temp), pre_p);
+ gimplify_vla_decl (temp, pre_p);
+ }
+ else
+ gimple_add_tmp_var (temp);
/* If TARGET_EXPR_INITIAL is void, then the mere evaluation of the
expression is supposed to initialize the slot. */
--- gcc/testsuite/gcc.c-torture/execute/20070919-1.c (revision 0)
+++ gcc/testsuite/gcc.c-torture/execute/20070919-1.c (revision 128629)
@@ -0,0 +1,41 @@
+/* PR c/33238 */
+
+typedef __SIZE_TYPE__ size_t;
+int memcmp (const void *, const void *, size_t);
+void abort (void);
+
+void
+__attribute__((noinline))
+bar (void *x, void *y)
+{
+ struct S { char w[8]; } *p = x, *q = y;
+ if (memcmp (p->w, "zyxwvut", 8) != 0)
+ abort ();
+ if (memcmp (q[0].w, "abcdefg", 8) != 0)
+ abort ();
+ if (memcmp (q[1].w, "ABCDEFG", 8) != 0)
+ abort ();
+ if (memcmp (q[2].w, "zyxwvut", 8) != 0)
+ abort ();
+ if (memcmp (q[3].w, "zyxwvut", 8) != 0)
+ abort ();
+}
+
+void
+__attribute__((noinline))
+foo (void *x, int y)
+{
+ struct S { char w[y]; } *p = x, a;
+ int i;
+ a = ({ struct S b; b = p[2]; p[3] = b; });
+ bar (&a, x);
+}
+
+int
+main (void)
+{
+ struct S { char w[8]; } p[4]
+ = { "abcdefg", "ABCDEFG", "zyxwvut", "ZYXWVUT" };
+ foo (p, 8);
+ return 0;
+}
--- gcc/testsuite/gcc.dg/pr33238.c (revision 0)
+++ gcc/testsuite/gcc.dg/pr33238.c (revision 128629)
@@ -0,0 +1,12 @@
+/* PR c/33238 */
+/* { dg-do compile } */
+/* { dg-options "-std=gnu89" } */
+
+void
+reverse (void *x, int y, int z)
+{
+ struct { char w[z]; } *p = x, a;
+ int i, j;
+ for (i = y - 1, j = 0; j < y / 2; i--, j++)
+ ({ a = p[i]; p[i] = p[j]; p[j] = a; });
+}
--- gcc/testsuite/gcc.dg/pr27301.c (revision 0)
+++ gcc/testsuite/gcc.dg/pr27301.c (revision 128629)
@@ -0,0 +1,15 @@
+/* PR c/27301 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -std=gnu89" } */
+
+void
+foo (void *ptr, long n)
+{
+ __asm__ __volatile__ ("" :: "m" (({ struct { char x[n]; } *p = ptr; *p; })));
+}
+
+void
+bar (void *ptr, long n)
+{
+ __asm__ __volatile__ ("" :: "m" (*({ struct { char x[n]; } *p = ptr; p; })));
+}

77
gcc41-pr33619.patch Normal file
View File

@ -0,0 +1,77 @@
2007-10-15 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/33619
* tree-outof-ssa.c (check_replaceable): Return false for all
calls other than __builtin_expect.
* gcc.dg/pr33619.c: New test.
--- gcc/tree-outof-ssa.c 2007-10-11 22:01:41.000000000 +0200
+++ gcc/tree-outof-ssa.c 2007-10-16 14:28:42.000000000 +0200
@@ -1570,12 +1570,14 @@ check_replaceable (temp_expr_table_p tab
if (flag_float_store && FLOAT_TYPE_P (TREE_TYPE (TREE_OPERAND (stmt, 1))))
return false;
- /* Calls to functions with side-effects cannot be replaced. */
+ /* No calls to functions other than __builtin_expect are replaceable. */
if ((call_expr = get_call_expr_in (stmt)) != NULL_TREE)
{
- int call_flags = call_expr_flags (call_expr);
- if (TREE_SIDE_EFFECTS (call_expr)
- && !(call_flags & (ECF_PURE | ECF_CONST | ECF_NORETURN)))
+ tree fndecl = get_callee_fndecl (call_expr);
+
+ if (fndecl == NULL_TREE
+ || DECL_BUILT_IN_CLASS (fndecl) != BUILT_IN_NORMAL
+ || DECL_FUNCTION_CODE (fndecl) != BUILT_IN_EXPECT)
return false;
}
--- gcc/testsuite/gcc.dg/pr33619.c (revision 0)
+++ gcc/testsuite/gcc.dg/pr33619.c (revision 129350)
@@ -0,0 +1,45 @@
+/* PR tree-optimization/33619 */
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+#ifdef __powerpc__
+# define REG1 __asm__ ("3")
+# define REG2 __asm__ ("4")
+#elif defined __x86_64__
+# define REG1 __asm__ ("rdi")
+# define REG2 __asm__ ("rsi")
+#else
+# define REG1
+# define REG2
+#endif
+
+static inline void
+bar (unsigned long x, int y)
+{
+ register unsigned long p1 REG1 = x;
+ register unsigned long p2 REG2 = y;
+ __asm__ volatile ("" : "=r" (p1), "=r" (p2) : "0" (p1), "1" (p2) : "memory");
+ if (p1 != 0xdeadUL || p2 != 0xbefUL)
+ __builtin_abort ();
+}
+
+__attribute__((const, noinline)) int
+baz (int x)
+{
+ return x;
+}
+
+__attribute__((noinline)) void
+foo (unsigned long *x, int y)
+{
+ unsigned long a = *x;
+ bar (a, baz (y));
+}
+
+int
+main (void)
+{
+ unsigned long a = 0xdeadUL;
+ foo (&a, 0xbefUL);
+ return 0;
+}

84
gcc41-pr33639.patch Normal file
View File

@ -0,0 +1,84 @@
2007-10-03 Andrew Haley <aph@redhat.com>
PR java/33639
* class.c (mangled_classname): Detect and replace illegal
characters in assembly language symbols.
(gen_indirect_dispatch_tables): Call mangled_classname() on
the type.
--- gcc/java/class.c (revision 128980)
+++ gcc/java/class.c (revision 128981)
@@ -314,10 +314,63 @@ identifier_subst (const tree old_id,
tree
mangled_classname (const char *prefix, tree type)
{
+ tree result;
tree ident = TYPE_NAME (type);
if (TREE_CODE (ident) != IDENTIFIER_NODE)
ident = DECL_NAME (ident);
- return identifier_subst (ident, prefix, '.', '_', "");
+ result = identifier_subst (ident, prefix, '.', '_', "");
+
+ /* Replace any characters that aren't in the set [0-9a-zA-Z_$] with
+ "_0xXX". Class names containing such chracters are uncommon, but
+ they do sometimes occur in class files. Without this check,
+ these names cause assembly errors.
+
+ There is a possibility that a real class name could conflict with
+ the identifier we generate, but it is unlikely and will
+ immediately be detected as an assembler error. At some point we
+ should do something more elaborate (perhaps using the full
+ unicode mangling scheme) in order to prevent such a conflict. */
+ {
+ int i;
+ const int len = IDENTIFIER_LENGTH (result);
+ const char *p = IDENTIFIER_POINTER (result);
+ int illegal_chars = 0;
+
+ /* Make two passes over the identifier. The first pass is merely
+ to count illegal characters; we need to do this in order to
+ allocate a buffer. */
+ for (i = 0; i < len; i++)
+ {
+ char c = p[i];
+ illegal_chars += (! ISALNUM (c) && c != '_' && c != '$');
+ }
+
+ /* And the second pass, which is rarely executed, does the
+ rewriting. */
+ if (illegal_chars != 0)
+ {
+ char *buffer = alloca (illegal_chars * 4 + len + 1);
+ int j;
+
+ for (i = 0, j = 0; i < len; i++)
+ {
+ char c = p[i];
+ if (! ISALNUM (c) && c != '_' && c != '$')
+ {
+ buffer[j++] = '_';
+ sprintf (&buffer[j], "0x%02x", c);
+ j += 4;
+ }
+ else
+ buffer[j++] = c;
+ }
+
+ buffer[j] = 0;
+ result = get_identifier (buffer);
+ }
+ }
+
+ return result;
}
tree
@@ -389,7 +442,7 @@ while (0)
void
gen_indirect_dispatch_tables (tree type)
{
- const char *typename = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
+ const char *typename = IDENTIFIER_POINTER (mangled_classname ("", type));
{
tree field = NULL;
char *buf = alloca (strlen (typename) + strlen ("_catch_classes_") + 1);

67
gcc41-pr33744.patch Normal file
View File

@ -0,0 +1,67 @@
2007-10-15 Jakub Jelinek <jakub@redhat.com>
PR c++/33744
* parser.c (cp_parser_parenthesized_expression_list): Set
greater_than_is_operator_p to true in between the parens.
* g++.dg/template/arg6.C: New test.
--- gcc/cp/parser.c.jj 2007-10-12 00:28:24.000000000 +0200
+++ gcc/cp/parser.c 2007-10-15 14:52:02.000000000 +0200
@@ -4976,6 +4976,7 @@ cp_parser_parenthesized_expression_list
tree expression_list = NULL_TREE;
bool fold_expr_p = is_attribute_list;
tree identifier = NULL_TREE;
+ bool saved_greater_than_is_operator_p;
/* Assume all the expressions will be constant. */
if (non_constant_p)
@@ -4984,6 +4985,12 @@ cp_parser_parenthesized_expression_list
if (!cp_parser_require (parser, CPP_OPEN_PAREN, "`('"))
return error_mark_node;
+ /* Within a parenthesized expression, a `>' token is always
+ the greater-than operator. */
+ saved_greater_than_is_operator_p
+ = parser->greater_than_is_operator_p;
+ parser->greater_than_is_operator_p = true;
+
/* Consume expressions until there are no more. */
if (cp_lexer_next_token_is_not (parser->lexer, CPP_CLOSE_PAREN))
while (true)
@@ -5069,9 +5076,16 @@ cp_parser_parenthesized_expression_list
if (ending < 0)
goto get_comma;
if (!ending)
- return error_mark_node;
+ {
+ parser->greater_than_is_operator_p
+ = saved_greater_than_is_operator_p;
+ return error_mark_node;
+ }
}
+ parser->greater_than_is_operator_p
+ = saved_greater_than_is_operator_p;
+
/* We built up the list in reverse order so we must reverse it now. */
expression_list = nreverse (expression_list);
if (identifier)
--- gcc/testsuite/g++.dg/template/arg6.C.jj 2007-10-15 14:59:13.000000000 +0200
+++ gcc/testsuite/g++.dg/template/arg6.C 2007-10-15 14:57:31.000000000 +0200
@@ -0,0 +1,15 @@
+// PR c++/33744
+// { dg-do run }
+
+template <bool B> struct A { bool b; A() : b(B) {}; };
+A<bool(1)> a;
+A<bool(1<2)> b;
+A<(bool)(2>1)> c;
+A<bool((2>1))> d;
+A<bool(2>1)> e;
+
+int
+main ()
+{
+ return (a.b && b.b && c.b && d.b && e.b) ? 0 : 1;
+}

153
gcc41-pr33763.patch Normal file
View File

@ -0,0 +1,153 @@
2007-10-16 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/33763
* gcc.dg/pr33763.c: New test.
* g++.dg/opt/inline12.C: New test.
2007-10-14 Jan Hubicka <jh@suse.cz>
PR tree-optimization/33763
* tree-inline.c (expand_call_inline): Silently ignore always_inline
attribute for redefined extern inline functions.
--- gcc/tree-inline.c.jj 2007-09-25 12:23:05.000000000 +0200
+++ gcc/tree-inline.c 2007-10-16 15:27:51.000000000 +0200
@@ -2059,6 +2059,12 @@ expand_call_inline (basic_block bb, tree
if (!cgraph_inline_p (cg_edge, &reason))
{
if (lookup_attribute ("always_inline", DECL_ATTRIBUTES (fn))
+ /* For extern inline functions that get redefined we always
+ silently ignored alway_inline flag. Better behaviour would
+ be to be able to keep both bodies and use extern inline body
+ for inlining, but we can't do that because frontends overwrite
+ the body. */
+ && !cg_edge->callee->local.redefined_extern_inline
/* Avoid warnings during early inline pass. */
&& (!flag_unit_at_a_time || cgraph_global_info_ready))
{
--- gcc/testsuite/gcc.dg/pr33763.c.jj 2007-10-16 15:20:41.000000000 +0200
+++ gcc/testsuite/gcc.dg/pr33763.c 2007-10-16 15:20:35.000000000 +0200
@@ -0,0 +1,60 @@
+/* PR tree-optimization/33763 */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+typedef struct
+{
+ void *a;
+ void *b;
+} T;
+extern void *foo (const char *, const char *);
+extern void *bar (void *, const char *, T);
+extern int baz (const char *, int);
+
+extern inline __attribute__ ((always_inline, gnu_inline)) int
+baz (const char *x, int y)
+{
+ return 2;
+}
+
+int
+baz (const char *x, int y)
+{
+ return 1;
+}
+
+int xa, xb;
+
+static void *
+inl (const char *x, const char *y)
+{
+ T t = { &xa, &xb };
+ int *f = (int *) __builtin_malloc (sizeof (int));
+ const char *z;
+ int o = 0;
+ void *r = 0;
+
+ for (z = y; *z; z++)
+ {
+ if (*z == 'r')
+ o |= 1;
+ if (*z == 'w')
+ o |= 2;
+ }
+ if (o == 1)
+ *f = baz (x, 0);
+ if (o == 2)
+ *f = baz (x, 1);
+ if (o == 3)
+ *f = baz (x, 2);
+
+ if (o && *f > 0)
+ r = bar (f, "w", t);
+ return r;
+}
+
+void *
+foo (const char *x, const char *y)
+{
+ return inl (x, y);
+}
--- gcc/testsuite/g++.dg/opt/inline12.C.jj 2007-10-16 15:26:01.000000000 +0200
+++ gcc/testsuite/g++.dg/opt/inline12.C 2007-10-16 15:26:20.000000000 +0200
@@ -0,0 +1,60 @@
+// PR tree-optimization/33763
+// { dg-do compile }
+// { dg-options "-O2" }
+
+typedef struct
+{
+ void *a;
+ void *b;
+} T;
+extern void *foo (const char *, const char *);
+extern void *bar (void *, const char *, T);
+extern int baz (const char *, int);
+
+extern inline __attribute__ ((always_inline, gnu_inline)) int
+baz (const char *x, int y)
+{
+ return 2;
+}
+
+int
+baz (const char *x, int y)
+{
+ return 1;
+}
+
+int xa, xb;
+
+static void *
+inl (const char *x, const char *y)
+{
+ T t = { &xa, &xb };
+ int *f = (int *) __builtin_malloc (sizeof (int));
+ const char *z;
+ int o = 0;
+ void *r = 0;
+
+ for (z = y; *z; z++)
+ {
+ if (*z == 'r')
+ o |= 1;
+ if (*z == 'w')
+ o |= 2;
+ }
+ if (o == 1)
+ *f = baz (x, 0);
+ if (o == 2)
+ *f = baz (x, 1);
+ if (o == 3)
+ *f = baz (x, 2);
+
+ if (o && *f > 0)
+ r = bar (f, "w", t);
+ return r;
+}
+
+void *
+foo (const char *x, const char *y)
+{
+ return inl (x, y);
+}

291
gcc41-rh317051.patch Normal file
View File

@ -0,0 +1,291 @@
2006-07-26 Francois-Xavier Coudert <coudert@clipper.ens.fr>
* intrinsic.c (add_functions): Add INT2, SHORT, INT8, LONG,
LSTAT, MCLOCK and MCLOCK8 intrinsic functions.
(add_subroutines): Add LSTAT intrinsic subroutine.
* gfortran.h (gfc_generic_isym_id): Add GFC_ISYM_INT2,
GFC_ISYM_INT8, GFC_ISYM_LONG, GFC_ISYM_LSTAT, GFC_ISYM_MCLOCK
and GFC_ISYM_MCLOCK8.
* iresolve.c (gfc_resolve_int2, gfc_resolve_int8,
gfc_resolve_long, gfc_resolve_lstat, gfc_resolve_mclock,
gfc_resolve_mclock8, gfc_resolve_lstat_sub): New functions.
* check.c (gfc_check_intconv): New function.
* trans-intrinsic.c (gfc_conv_intrinsic_function): Add cases for
the added GFC_ISYM_*.
* simplify.c (gfc_simplify_intconv, gfc_simplify_int2,
gfc_simplify_int8, gfc_simplify_long): New functions.
* intrinsic.h (gfc_check_intconv, gfc_simplify_int2,
gfc_simplify_int8, gfc_simplify_long, gfc_resolve_int2,
gfc_resolve_int8, gfc_resolve_long, gfc_resolve_lstat,
gfc_resolve_mclock, gfc_resolve_mclock8, gfc_resolve_lstat_sub):
Add prototypes.
* gfortran.dg/int_conv_1.f90: New test.
--- gcc/testsuite/gfortran.dg/int_conv_1.f90 (revision 0)
+++ gcc/testsuite/gfortran.dg/int_conv_1.f90 (revision 115754)
@@ -0,0 +1,36 @@
+! { dg-do run }
+! { dg-options "-std=gnu" }
+ integer(kind=2) :: i2, j2, k2, l2, m2, n2, o2
+ integer(kind=4) :: i4, j4
+ integer(kind=8) :: i8, j8
+ real :: x
+ complex :: z
+
+ i2 = huge(i2) / 3
+ i8 = int8(i2)
+ i4 = long(i2)
+ j2 = short(i2)
+ k2 = int2(i2)
+ l2 = int2(i8)
+ m2 = short(i8)
+ n2 = int2(i4)
+ o2 = short(i4)
+
+ if (i8 /= i2 .or. i4 /= i2 .or. j2 /= i2 .or. k2 /= i2 &
+ .or. l2 /= i2 .or. m2 /= i2 .or. n2 /= i2 .or. o2 /= i2) call abort
+
+ x = i2
+ i8 = int8(x)
+ i4 = long(x)
+ j2 = short(x)
+ k2 = int2(x)
+ if (i8 /= i2 .or. i4 /= i2 .or. j2 /= i2 .or. k2 /= i2) call abort
+
+ z = i2 + (0.,-42.)
+ i8 = int8(z)
+ i4 = long(z)
+ j2 = short(z)
+ k2 = int2(z)
+ if (i8 /= i2 .or. i4 /= i2 .or. j2 /= i2 .or. k2 /= i2) call abort
+
+ end
--- gcc/fortran/intrinsic.c (revision 115753)
+++ gcc/fortran/intrinsic.c (revision 115754)
@@ -1535,6 +1535,26 @@ add_functions (void)
make_generic ("int", GFC_ISYM_INT, GFC_STD_F77);
+ add_sym_1 ("int2", 1, 0, BT_INTEGER, di, GFC_STD_GNU,
+ gfc_check_intconv, gfc_simplify_int2, gfc_resolve_int2,
+ a, BT_REAL, dr, REQUIRED);
+
+ make_alias ("short", GFC_STD_GNU);
+
+ make_generic ("int2", GFC_ISYM_INT2, GFC_STD_GNU);
+
+ add_sym_1 ("int8", 1, 0, BT_INTEGER, di, GFC_STD_GNU,
+ gfc_check_intconv, gfc_simplify_int8, gfc_resolve_int8,
+ a, BT_REAL, dr, REQUIRED);
+
+ make_generic ("int8", GFC_ISYM_INT8, GFC_STD_GNU);
+
+ add_sym_1 ("long", 1, 0, BT_INTEGER, di, GFC_STD_GNU,
+ gfc_check_intconv, gfc_simplify_long, gfc_resolve_long,
+ a, BT_REAL, dr, REQUIRED);
+
+ make_generic ("long", GFC_ISYM_LONG, GFC_STD_GNU);
+
add_sym_2 ("ior", 1, 1, BT_INTEGER, di, GFC_STD_F95,
gfc_check_ior, gfc_simplify_ior, gfc_resolve_ior,
i, BT_INTEGER, di, REQUIRED, j, BT_INTEGER, di, REQUIRED);
--- gcc/fortran/intrinsic.h (revision 115753)
+++ gcc/fortran/intrinsic.h (revision 115754)
@@ -74,6 +74,7 @@ try gfc_check_idnint (gfc_expr *);
try gfc_check_ieor (gfc_expr *, gfc_expr *);
try gfc_check_index (gfc_expr *, gfc_expr *, gfc_expr *);
try gfc_check_int (gfc_expr *, gfc_expr *);
+try gfc_check_intconv (gfc_expr *);
try gfc_check_ior (gfc_expr *, gfc_expr *);
try gfc_check_irand (gfc_expr *);
try gfc_check_isatty (gfc_expr *);
@@ -222,6 +223,9 @@ gfc_expr *gfc_simplify_ichar (gfc_expr *
gfc_expr *gfc_simplify_ieor (gfc_expr *, gfc_expr *);
gfc_expr *gfc_simplify_index (gfc_expr *, gfc_expr *, gfc_expr *);
gfc_expr *gfc_simplify_int (gfc_expr *, gfc_expr *);
+gfc_expr *gfc_simplify_int2 (gfc_expr *);
+gfc_expr *gfc_simplify_int8 (gfc_expr *);
+gfc_expr *gfc_simplify_long (gfc_expr *);
gfc_expr *gfc_simplify_ifix (gfc_expr *);
gfc_expr *gfc_simplify_idint (gfc_expr *);
gfc_expr *gfc_simplify_ior (gfc_expr *, gfc_expr *);
@@ -352,6 +356,9 @@ void gfc_resolve_ieor (gfc_expr *, gfc_e
void gfc_resolve_ichar (gfc_expr *, gfc_expr *);
void gfc_resolve_idnint (gfc_expr *, gfc_expr *);
void gfc_resolve_int (gfc_expr *, gfc_expr *, gfc_expr *);
+void gfc_resolve_int2 (gfc_expr *, gfc_expr *);
+void gfc_resolve_int8 (gfc_expr *, gfc_expr *);
+void gfc_resolve_long (gfc_expr *, gfc_expr *);
void gfc_resolve_ior (gfc_expr *, gfc_expr *, gfc_expr *);
void gfc_resolve_isatty (gfc_expr *, gfc_expr *);
void gfc_resolve_ishft (gfc_expr *, gfc_expr *, gfc_expr *);
--- gcc/fortran/gfortran.h (revision 115753)
+++ gcc/fortran/gfortran.h (revision 115754)
@@ -377,6 +377,8 @@ enum gfc_generic_isym_id
GFC_ISYM_IERRNO,
GFC_ISYM_INDEX,
GFC_ISYM_INT,
+ GFC_ISYM_INT2,
+ GFC_ISYM_INT8,
GFC_ISYM_IOR,
GFC_ISYM_IRAND,
GFC_ISYM_ISATTY,
@@ -391,10 +393,11 @@ enum gfc_generic_isym_id
GFC_ISYM_LGT,
GFC_ISYM_LLE,
GFC_ISYM_LLT,
- GFC_ISYM_LOG,
GFC_ISYM_LOC,
+ GFC_ISYM_LOG,
GFC_ISYM_LOG10,
GFC_ISYM_LOGICAL,
+ GFC_ISYM_LONG,
GFC_ISYM_MALLOC,
GFC_ISYM_MATMUL,
GFC_ISYM_MAX,
--- gcc/fortran/iresolve.c (revision 115753)
+++ gcc/fortran/iresolve.c (revision 115754)
@@ -854,6 +854,42 @@ gfc_resolve_int (gfc_expr * f, gfc_expr
void
+gfc_resolve_int2 (gfc_expr * f, gfc_expr * a)
+{
+ f->ts.type = BT_INTEGER;
+ f->ts.kind = 2;
+
+ f->value.function.name =
+ gfc_get_string ("__int_%d_%c%d", f->ts.kind, gfc_type_letter (a->ts.type),
+ a->ts.kind);
+}
+
+
+void
+gfc_resolve_int8 (gfc_expr * f, gfc_expr * a)
+{
+ f->ts.type = BT_INTEGER;
+ f->ts.kind = 8;
+
+ f->value.function.name =
+ gfc_get_string ("__int_%d_%c%d", f->ts.kind, gfc_type_letter (a->ts.type),
+ a->ts.kind);
+}
+
+
+void
+gfc_resolve_long (gfc_expr * f, gfc_expr * a)
+{
+ f->ts.type = BT_INTEGER;
+ f->ts.kind = 4;
+
+ f->value.function.name =
+ gfc_get_string ("__int_%d_%c%d", f->ts.kind, gfc_type_letter (a->ts.type),
+ a->ts.kind);
+}
+
+
+void
gfc_resolve_isatty (gfc_expr * f, gfc_expr * u)
{
gfc_typespec ts;
--- gcc/fortran/check.c (revision 115753)
+++ gcc/fortran/check.c (revision 115754)
@@ -1200,6 +1200,16 @@ gfc_check_int (gfc_expr * x, gfc_expr *
try
+gfc_check_intconv (gfc_expr * x)
+{
+ if (numeric_check (x, 0) == FAILURE)
+ return FAILURE;
+
+ return SUCCESS;
+}
+
+
+try
gfc_check_ior (gfc_expr * i, gfc_expr * j)
{
if (type_check (i, 0, BT_INTEGER) == FAILURE)
--- gcc/fortran/trans-intrinsic.c (revision 115753)
+++ gcc/fortran/trans-intrinsic.c (revision 115754)
@@ -3477,6 +3477,9 @@ gfc_conv_intrinsic_function (gfc_se * se
/* Integer conversions are handled separately to make sure we get the
correct rounding mode. */
case GFC_ISYM_INT:
+ case GFC_ISYM_INT2:
+ case GFC_ISYM_INT8:
+ case GFC_ISYM_LONG:
gfc_conv_intrinsic_int (se, expr, FIX_TRUNC_EXPR);
break;
--- gcc/fortran/simplify.c (revision 115753)
+++ gcc/fortran/simplify.c (revision 115754)
@@ -1610,6 +1610,66 @@ gfc_simplify_int (gfc_expr * e, gfc_expr
}
+static gfc_expr *
+gfc_simplify_intconv (gfc_expr * e, int kind, const char *name)
+{
+ gfc_expr *rpart, *rtrunc, *result;
+
+ if (e->expr_type != EXPR_CONSTANT)
+ return NULL;
+
+ result = gfc_constant_result (BT_INTEGER, kind, &e->where);
+
+ switch (e->ts.type)
+ {
+ case BT_INTEGER:
+ mpz_set (result->value.integer, e->value.integer);
+ break;
+
+ case BT_REAL:
+ rtrunc = gfc_copy_expr (e);
+ mpfr_trunc (rtrunc->value.real, e->value.real);
+ gfc_mpfr_to_mpz (result->value.integer, rtrunc->value.real);
+ gfc_free_expr (rtrunc);
+ break;
+
+ case BT_COMPLEX:
+ rpart = gfc_complex2real (e, kind);
+ rtrunc = gfc_copy_expr (rpart);
+ mpfr_trunc (rtrunc->value.real, rpart->value.real);
+ gfc_mpfr_to_mpz (result->value.integer, rtrunc->value.real);
+ gfc_free_expr (rpart);
+ gfc_free_expr (rtrunc);
+ break;
+
+ default:
+ gfc_error ("Argument of %s at %L is not a valid type", name, &e->where);
+ gfc_free_expr (result);
+ return &gfc_bad_expr;
+ }
+
+ return range_check (result, name);
+}
+
+gfc_expr *
+gfc_simplify_int2 (gfc_expr * e)
+{
+ return gfc_simplify_intconv (e, 2, "INT2");
+}
+
+gfc_expr *
+gfc_simplify_int8 (gfc_expr * e)
+{
+ return gfc_simplify_intconv (e, 8, "INT8");
+}
+
+gfc_expr *
+gfc_simplify_long (gfc_expr * e)
+{
+ return gfc_simplify_intconv (e, 4, "LONG");
+}
+
+
gfc_expr *
gfc_simplify_ifix (gfc_expr * e)
{

34
gcc41-rh330771.patch Normal file
View File

@ -0,0 +1,34 @@
2007-10-16 Jakub Jelinek <jakub@redhat.com>
* Makefile.am (libgcj_tools_la_LIBADD): Add.
* Makefile.in: Regenerated.
--- libjava/Makefile.am.jj 2007-03-17 09:20:30.000000000 +0100
+++ libjava/Makefile.am 2007-10-16 15:45:14.000000000 +0200
@@ -262,6 +262,8 @@ EXTRA_libgcj_la_SOURCES = java/lang/Obje
libgcj_tools_la_SOURCES = classpath/tools/tools.zip
libgcj_tools_la_GCJFLAGS = $(AM_GCJFLAGS) -findirect-dispatch -fno-indirect-classes -fsource-filename=$(here)/classpath/tools/all-classes.lst
+## See jv_convert_LDADD.
+libgcj_tools_la_LIBADD = -L$(here)/.libs libgcj.la
libgcj_tools_la_LDFLAGS = -rpath $(toolexeclibdir) \
-version-info `grep -v '^\#' $(srcdir)/libtool-version`
libgcj_tools_la_DEPENDENCIES = libgcj.la libgcj.spec
--- libjava/Makefile.in.jj 2007-07-04 21:11:11.000000000 +0200
+++ libjava/Makefile.in 2007-10-16 15:56:07.000000000 +0200
@@ -146,7 +146,6 @@ am__objects_1 = gnu/gcj/xlib/lib_gnu_awt
am_lib_gnu_awt_xlib_la_OBJECTS = $(am__objects_1)
lib_gnu_awt_xlib_la_OBJECTS = $(am_lib_gnu_awt_xlib_la_OBJECTS)
@XLIB_AWT_TRUE@am_lib_gnu_awt_xlib_la_rpath = -rpath $(toolexeclibdir)
-libgcj_tools_la_LIBADD =
am_libgcj_tools_la_OBJECTS = classpath/tools/libgcj_tools_la-tools.lo
libgcj_tools_la_OBJECTS = $(am_libgcj_tools_la_OBJECTS)
am__DEPENDENCIES_1 = gnu/awt.lo gnu/awt/j2d.lo gnu/classpath.lo \
@@ -894,6 +893,7 @@ libgcj_la_LINK = $(LIBLINK)
EXTRA_libgcj_la_SOURCES = java/lang/Object.java
libgcj_tools_la_SOURCES = classpath/tools/tools.zip
libgcj_tools_la_GCJFLAGS = $(AM_GCJFLAGS) -findirect-dispatch -fno-indirect-classes -fsource-filename=$(here)/classpath/tools/all-classes.lst
+libgcj_tools_la_LIBADD = -L$(here)/.libs libgcj.la
libgcj_tools_la_LDFLAGS = -rpath $(toolexeclibdir) \
-version-info `grep -v '^\#' $(srcdir)/libtool-version`

View File

@ -1,6 +1,6 @@
%define DATE 20070925
%define gcc_version 4.1.2
%define gcc_release 31
%define gcc_release 32
%define _unpackaged_files_terminate_build 0
%define multilib_64_archs sparc64 ppc64 s390x x86_64
%define include_gappletviewer 1
@ -149,6 +149,15 @@ Patch32: gcc41-virtual-inline-backtrace.patch
Patch33: gcc41-c++-gnu-inline-redecl.patch
Patch34: gcc41-c++-builtin-redecl.patch
Patch35: gcc41-c++-guard-visibility.patch
Patch36: gcc41-pr32121.patch
Patch37: gcc41-pr33136.patch
Patch38: gcc41-pr33238.patch
Patch39: gcc41-pr33619.patch
Patch40: gcc41-pr33639.patch
Patch41: gcc41-pr33744.patch
Patch42: gcc41-pr33763.patch
Patch43: gcc41-rh317051.patch
Patch44: gcc41-rh330771.patch
# On ARM EABI systems, we do want -gnueabi to be part of the
# target triple.
@ -467,6 +476,15 @@ which are required to run programs compiled with the GNAT.
%patch33 -p0 -b .c++-gnu-inline-redecl~
%patch34 -p0 -b .c++-builtin-redecl~
%patch35 -p0 -b .c++-guard-visibility~
%patch36 -p0 -b .pr32121~
%patch37 -p0 -b .pr33136~
%patch38 -p0 -b .pr33238~
%patch39 -p0 -b .pr33619~
%patch40 -p0 -b .pr33639~
%patch41 -p0 -b .pr33744~
%patch42 -p0 -b .pr33763~
%patch43 -p0 -b .rh317051~
%patch44 -p0 -b .rh330771~
sed -i -e 's/4\.1\.3/4.1.2/' gcc/BASE-VER gcc/version.c
sed -i -e 's/" (Red Hat[^)]*)"/" (Red Hat %{version}-%{gcc_release})"/' gcc/version.c
@ -1621,6 +1639,22 @@ fi
%doc rpm.doc/changelogs/libmudflap/ChangeLog*
%changelog
* Tue Oct 16 2007 Jakub Jelinek <jakub@redhat.com> 4.1.2-32
- only allow __label__ at the start of a block (PR c++/32121)
- disable -fipa-type-escape by default (PR tree-optimization/33136)
- VLA handling fix (PR c/33238, PR c/27301)
- disable TER of pure and const function calls except for __builtin_expect
(PR tree-optimization/33619)
- handle classes with characters other than [a-zA-Z0-9_$] in
their names (Andrew Haley, #297961, PR java/33639)
- fix parsing of C++ function-like cast in template argument where cast's
argument uses greater-than operator (PR c++/33744)
- ignore always_inline attribute on redefined extern inline
functions (Jan Hubicka, #329671, PR tree-optimization/33763)
- add support for Fortran int conversion intrinsics (Francois-Xavier
Coudert, #317051)
- link libgcj-tools.so* against libgcj.so* (#330771)
* Wed Oct 3 2007 Jakub Jelinek <jakub@redhat.com> 4.1.2-31
- fix visibility of C++ guard variables (Jason Merrill)
- don't drop DECL_BUILT_IN_CLASS when defining a builtin function