summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/uninit-A-O0.c
diff options
context:
space:
mode:
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2008-07-31 10:25:11 +0000
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2008-07-31 10:25:11 +0000
commitea18e2e5e2938b795b8283032c6e7dd5f51e8e21 (patch)
treeafc954a72895d46b605daa3cc053cbe20525a974 /gcc/testsuite/gcc.dg/uninit-A-O0.c
parent9074c0d883a5ea6b36aeb6358c41e93d817bb590 (diff)
downloadgcc-ea18e2e5e2938b795b8283032c6e7dd5f51e8e21.tar.gz
2008-07-31 Richard Guenther <rguenther@suse.de>
* passes.c (init_optimization_passes): Always call pass_early_warn_uninitialized. * opts.c (decode_options): Do not warn about -Wuninitialized at -O0. * doc/invoke.texi (-Wuninitialized): Correct for enabling at -O0. * doc/passes.texi (Warn for uninitialized variables): Adjust. * gcc.dg/uninit-1-O0.c: New testcase. * gcc.dg/uninit-2-O0.c: Likewise. * gcc.dg/uninit-3-O0.c: Likewise. * gcc.dg/uninit-4-O0.c: Likewise. * gcc.dg/uninit-5-O0.c: Likewise. * gcc.dg/uninit-6-O0.c: Likewise. * gcc.dg/uninit-8-O0.c: Likewise. * gcc.dg/uninit-9-O0.c: Likewise. * gcc.dg/uninit-A-O0.c: Likewise. * gcc.dg/uninit-B-O0.c: Likewise. * gcc.dg/uninit-C-O0.c: Likewise. * gcc.dg/uninit-D-O0.c: Likewise. * gcc.dg/uninit-E-O0.c: Likewise. * gcc.dg/uninit-F-O0.c: Likewise. * gcc.dg/uninit-G-O0.c: Likewise. * gcc.dg/uninit-H-O0.c: Likewise. * gcc.dg/uninit-I-O0.c: Likewise. * gcc.dg/uninit-10-O0.c: Likewise. * gcc.dg/uninit-11-O0.c: Likewise. * gcc.dg/uninit-12-O0.c: Likewise. * gcc.dg/uninit-13-O0.c: Likewise. * gcc.dg/uninit-14-O0.c: Likewise. * gcc.dg/uninit-15-O0.c: Likewise. * gcc.dg/Wall.c: Avoid uninitialized warning. * gcc.dg/Wno-all.c: Likewise. * gcc.dg/pr3074-1.c: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@138376 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/gcc.dg/uninit-A-O0.c')
-rw-r--r--gcc/testsuite/gcc.dg/uninit-A-O0.c117
1 files changed, 117 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/uninit-A-O0.c b/gcc/testsuite/gcc.dg/uninit-A-O0.c
new file mode 100644
index 00000000000..69376911563
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/uninit-A-O0.c
@@ -0,0 +1,117 @@
+/* Inspired by part of java/parse.y.
+ May be a real bug in CSE. */
+
+/* { dg-do compile } */
+/* { dg-options "-Wall" } */
+
+struct tree
+{
+ struct tree *car, *cdr, *wfl;
+ int code;
+ struct { unsigned int renp:1;
+ unsigned int rtnp:1;
+ unsigned int rpnp:1; } flags;
+};
+typedef struct tree *tree;
+#define NULL_TREE ((tree)0)
+
+/* Codes */
+enum
+{
+ CALL_EXPR, NEW_ARRAY_EXPR, NEW_CLASS_EXPR, CONVERT_EXPR,
+ ARRAY_REF, CONDITIONAL_EXPR, STRING_CST, EXPR_WITH_FILE_LOCATION
+};
+
+/* Flags */
+#define RESOLVE_EXPRESSION_NAME_P(t) ((t)->flags.renp)
+#define RESOLVE_TYPE_NAME_P(t) ((t)->flags.rtnp)
+#define RESOLVE_PACKAGE_NAME_P(t) ((t)->flags.rpnp)
+
+/* Macros */
+#define EXPR_WFL_QUALIFICATION(t) ((t)->wfl)
+#define QUAL_WFL(t) ((t)->wfl)
+#define EXPR_WFL_NODE(t) ((t)->wfl)
+#define TREE_CODE(t) ((t)->code)
+#define TREE_OPERAND(t,x) ((t)->car)
+#define CLASSTYPE_SUPER(t) ((t)->car)
+#define IDENTIFIER_LOCAL_VALUE(t) ((t)->car)
+#define TREE_CHAIN(t) ((t)->cdr)
+#define QUAL_RESOLUTION(t) ((t)->cdr)
+
+extern tree current_class, this_identifier_node;
+extern tree super_identifier_node, length_identifier_node;
+
+tree resolve_and_layout (tree, tree);
+tree lookup_field_wrapper (tree, tree);
+
+void
+qualify_ambiguous_name (id)
+ tree id;
+{
+ tree qual, qual_wfl, decl;
+ tree name; /* { dg-bogus "name" "uninitialized variable warning" } */
+ tree ptr_type; /* { dg-bogus "ptr_type" "uninitialized variable warning" } */
+ int again, new_array_found = 0;
+ int super_found = 0, this_found = 0;
+
+ qual = EXPR_WFL_QUALIFICATION (id);
+ do {
+ qual_wfl = QUAL_WFL (qual);
+ switch (TREE_CODE (qual_wfl))
+ {
+ case CALL_EXPR:
+ qual_wfl = TREE_OPERAND (qual_wfl, 0);
+ if (TREE_CODE (qual_wfl) != EXPR_WITH_FILE_LOCATION)
+ {
+ qual = EXPR_WFL_QUALIFICATION (qual_wfl);
+ qual_wfl = QUAL_WFL (qual);
+ }
+ break;
+ case NEW_ARRAY_EXPR:
+ qual = TREE_CHAIN (qual);
+ new_array_found = again = 1;
+ continue;
+ case NEW_CLASS_EXPR:
+ case CONVERT_EXPR:
+ qual_wfl = TREE_OPERAND (qual_wfl, 0);
+ break;
+ case ARRAY_REF:
+ while (TREE_CODE (qual_wfl) == ARRAY_REF)
+ qual_wfl = TREE_OPERAND (qual_wfl, 0);
+ break;
+ default:
+ break;
+ }
+
+ name = EXPR_WFL_NODE (qual_wfl);
+ ptr_type = current_class;
+ again = 0;
+
+ } while (again);
+
+ /* If you put straightforward uses of name and ptr_type here
+ instead of the if-else sequence below, the warnings go away.
+ Therefore I suspect a real bug. */
+
+ if (!this_found && !super_found && (decl = IDENTIFIER_LOCAL_VALUE (name)))
+ {
+ RESOLVE_EXPRESSION_NAME_P (qual_wfl) = 1;
+ QUAL_RESOLUTION (qual) = decl;
+ }
+ else if ((decl = lookup_field_wrapper (ptr_type, name))
+ || (new_array_found && name == length_identifier_node))
+ {
+ RESOLVE_EXPRESSION_NAME_P (qual_wfl) = 1;
+ QUAL_RESOLUTION (qual) = (new_array_found ? NULL_TREE : decl);
+ }
+ else if ((decl = resolve_and_layout (name, NULL_TREE)))
+ {
+ RESOLVE_TYPE_NAME_P (qual_wfl) = 1;
+ QUAL_RESOLUTION (qual) = decl;
+ }
+ else if (TREE_CODE (QUAL_WFL (qual)) == CALL_EXPR
+ || TREE_CODE (QUAL_WFL (qual)) == ARRAY_REF)
+ RESOLVE_EXPRESSION_NAME_P (qual_wfl) = 1;
+ else
+ RESOLVE_PACKAGE_NAME_P (qual_wfl) = 1;
+}