diff options
Diffstat (limited to 'gcc/testsuite/gcc.dg')
-rw-r--r-- | gcc/testsuite/gcc.dg/declspec-10.c | 8 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/declspec-11.c | 8 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/declspec-9.c | 8 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/dfp/pr39986.c | 31 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/noncompile/incomplete-5.c | 8 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/plugin/plugin.exp | 65 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/plugin/self-assign-test-1.c | 23 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/plugin/self-assign-test-2.c | 23 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/plugin/selfassign.c | 365 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pr39666-1.c | 22 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pr39666-2.c | 22 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/ucnid-10.c | 8 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/ucnid-11.c | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/ucnid-12.c | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/ucnid-13.c | 13 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/ucnid-8.c | 14 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/ucnid-9.c | 24 |
17 files changed, 640 insertions, 12 deletions
diff --git a/gcc/testsuite/gcc.dg/declspec-10.c b/gcc/testsuite/gcc.dg/declspec-10.c index d29fb7ab45a..f938bf10e7a 100644 --- a/gcc/testsuite/gcc.dg/declspec-10.c +++ b/gcc/testsuite/gcc.dg/declspec-10.c @@ -9,11 +9,11 @@ auto void f0 (void) {} /* { dg-warning "function definition declared 'auto'" } * register void f1 (void) {} /* { dg-error "function definition declared 'register'" } */ typedef void f2 (void) {} /* { dg-error "function definition declared 'typedef'" } */ -void f3 (auto int); /* { dg-error "storage class specified for parameter 'type name'" } */ -void f4 (extern int); /* { dg-error "storage class specified for parameter 'type name'" } */ +void f3 (auto int); /* { dg-error "storage class specified for unnamed parameter" } */ +void f4 (extern int); /* { dg-error "storage class specified for unnamed parameter" } */ void f5 (register int); -void f6 (static int); /* { dg-error "storage class specified for parameter 'type name'" } */ -void f7 (typedef int); /* { dg-error "storage class specified for parameter 'type name'" } */ +void f6 (static int); /* { dg-error "storage class specified for unnamed parameter" } */ +void f7 (typedef int); /* { dg-error "storage class specified for unnamed parameter" } */ auto int x; /* { dg-error "file-scope declaration of 'x' specifies 'auto'" } */ register int y; /* { dg-warning "file-scope declaration of 'y' specifies 'register'" } */ diff --git a/gcc/testsuite/gcc.dg/declspec-11.c b/gcc/testsuite/gcc.dg/declspec-11.c index 4204b6f2188..c3fec469a81 100644 --- a/gcc/testsuite/gcc.dg/declspec-11.c +++ b/gcc/testsuite/gcc.dg/declspec-11.c @@ -9,11 +9,11 @@ auto void f0 (void) {} /* { dg-error "function definition declared 'auto'" } */ register void f1 (void) {} /* { dg-error "function definition declared 'register'" } */ typedef void f2 (void) {} /* { dg-error "function definition declared 'typedef'" } */ -void f3 (auto int); /* { dg-error "storage class specified for parameter 'type name'" } */ -void f4 (extern int); /* { dg-error "storage class specified for parameter 'type name'" } */ +void f3 (auto int); /* { dg-error "storage class specified for unnamed parameter" } */ +void f4 (extern int); /* { dg-error "storage class specified for unnamed parameter" } */ void f5 (register int); -void f6 (static int); /* { dg-error "storage class specified for parameter 'type name'" } */ -void f7 (typedef int); /* { dg-error "storage class specified for parameter 'type name'" } */ +void f6 (static int); /* { dg-error "storage class specified for unnamed parameter" } */ +void f7 (typedef int); /* { dg-error "storage class specified for unnamed parameter" } */ auto int x; /* { dg-error "file-scope declaration of 'x' specifies 'auto'" } */ register int y; /* { dg-error "file-scope declaration of 'y' specifies 'register'" } */ diff --git a/gcc/testsuite/gcc.dg/declspec-9.c b/gcc/testsuite/gcc.dg/declspec-9.c index 670fe25cbc1..ece47c66fb1 100644 --- a/gcc/testsuite/gcc.dg/declspec-9.c +++ b/gcc/testsuite/gcc.dg/declspec-9.c @@ -10,11 +10,11 @@ auto void f0 (void) {} /* { dg-warning "function definition declared 'auto'" } * register void f1 (void) {} /* { dg-error "function definition declared 'register'" } */ typedef void f2 (void) {} /* { dg-error "function definition declared 'typedef'" } */ -void f3 (auto int); /* { dg-error "storage class specified for parameter 'type name'" } */ -void f4 (extern int); /* { dg-error "storage class specified for parameter 'type name'" } */ +void f3 (auto int); /* { dg-error "storage class specified for unnamed parameter" } */ +void f4 (extern int); /* { dg-error "storage class specified for unnamed parameter" } */ void f5 (register int); -void f6 (static int); /* { dg-error "storage class specified for parameter 'type name'" } */ -void f7 (typedef int); /* { dg-error "storage class specified for parameter 'type name'" } */ +void f6 (static int); /* { dg-error "storage class specified for unnamed parameter" } */ +void f7 (typedef int); /* { dg-error "storage class specified for unnamed parameter" } */ auto int x; /* { dg-error "file-scope declaration of 'x' specifies 'auto'" } */ register int y; diff --git a/gcc/testsuite/gcc.dg/dfp/pr39986.c b/gcc/testsuite/gcc.dg/dfp/pr39986.c new file mode 100644 index 00000000000..53bda3c824a --- /dev/null +++ b/gcc/testsuite/gcc.dg/dfp/pr39986.c @@ -0,0 +1,31 @@ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99" } */ + +/* Check that the compiler generates the correct decimal float constants. */ + +_Decimal32 a = 100.223df; +_Decimal32 b = -2.3df; +_Decimal64 c = 3.4e-4dd; +_Decimal64 d = -4.500dd; +_Decimal128 e = 5678901234567.89e+200dl; +_Decimal128 f = -678901.234e-6dl; + +/* The first value is DPD, the second is BID. The order differs depending + on whether the target is big-endian or little-endian. */ + +/* { dg-final { scan-assembler ".long\t(572653859|822183807)\n" } } */ + +/* { dg-final { scan-assembler ".long\t(-1572863965|-1308622825)\n" } } */ + +/* { dg-final { scan-assembler ".long\t(52|34)\n" } } */ +/* { dg-final { scan-assembler ".long\t(572784640|824180736)\n" } } */ + +/* { dg-final { scan-assembler ".long\t(4736|4500)\n" } } */ +/* { dg-final { scan-assembler ".long\t(-1574174720|-1319108608)\n" } } */ + +/* { dg-final { scan-assembler ".long\t(-1975952433|957645077)\n" } } */ +/* { dg-final { scan-assembler ".long\t(190215|132222)\n" } } */ +/* { dg-final { scan-assembler ".long\t(574193664|835452928)\n" } } */ + +/* { dg-final { scan-assembler ".long\t(931280180|678901234)\n" } } */ +/* { dg-final { scan-assembler ".long\t(-1576681472|-1339162624)\n" } } */ diff --git a/gcc/testsuite/gcc.dg/noncompile/incomplete-5.c b/gcc/testsuite/gcc.dg/noncompile/incomplete-5.c new file mode 100644 index 00000000000..049c34a20a9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/noncompile/incomplete-5.c @@ -0,0 +1,8 @@ +/* ICE on unnamed field with incomplete enum type: PR 40032. */ +/* { dg-do compile } */ +/* { dg-options "" } */ +struct A +{ + enum E : 8; /* { dg-warning "narrower than values of its type" } */ + /* { dg-error "has incomplete type" "incomplete" { target *-*-* } 6 } */ +}; diff --git a/gcc/testsuite/gcc.dg/plugin/plugin.exp b/gcc/testsuite/gcc.dg/plugin/plugin.exp new file mode 100644 index 00000000000..93c0c5cb848 --- /dev/null +++ b/gcc/testsuite/gcc.dg/plugin/plugin.exp @@ -0,0 +1,65 @@ +# Copyright (C) 2009 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCC; see the file COPYING3. If not see +# <http://www.gnu.org/licenses/>. + +# Test the functionality of the GCC plugin support + +load_lib target-supports.exp +load_lib gcc-dg.exp + +global TESTING_IN_BUILD_TREE +global ENABLE_PLUGIN + +# The plugin testcases currently only work when the build tree is available. +# Also check whether the host supports plugins. +if { ![info exists TESTING_IN_BUILD_TREE] || ![info exists ENABLE_PLUGIN] } { + return +} + +# If a testcase doesn't have special options, use these. +global DEFAULT_CFLAGS +if ![info exists DEFAULT_CFLAGS] then { + set DEFAULT_CFLAGS " -ansi -pedantic-errors" +} + +# The procedures in plugin-support.exp need these parameters. +set default_flags $DEFAULT_CFLAGS + +if $tracelevel then { + strace $tracelevel +} + +# Load support procs. +load_lib plugin-support.exp + +# Specify the plugin source file and the associated test files in a list. +# plugin_test_list={ {plugin1 test1 test2 ...} {plugin2 test1 ...} ... } +set plugin_test_list [list \ + { selfassign.c self-assign-test-1.c self-assign-test-2.c } ] + +foreach plugin_test $plugin_test_list { + # Replace each source file with its full-path name + for {set i 0} {$i < [llength $plugin_test]} {incr i} { + set basename [lindex $plugin_test $i] + set plugin_test [lreplace $plugin_test $i $i $srcdir/$subdir/$basename] + } + set plugin_src [lindex $plugin_test 0] + # If we're only testing specific files and this isn't one of them, skip it. + if ![runtest_file_p $runtests $plugin_src] then { + continue + } + set plugin_input_tests [lreplace $plugin_test 0 0] + plugin-test-execute $plugin_src $plugin_input_tests +} diff --git a/gcc/testsuite/gcc.dg/plugin/self-assign-test-1.c b/gcc/testsuite/gcc.dg/plugin/self-assign-test-1.c new file mode 100644 index 00000000000..f6dc5240f1e --- /dev/null +++ b/gcc/testsuite/gcc.dg/plugin/self-assign-test-1.c @@ -0,0 +1,23 @@ +/* Test the self-assignemnt detection plugin. */ +/* { dg-do compile } */ +/* { dg-options "-O" } */ + +struct Bar { + int b_; + int c_; +}; + +int g; + +int main() +{ + struct Bar *bar; + int x = x; /* { dg-warning "assigned to itself" } */ + static int y; + struct Bar b_array[5]; + + b_array[x+g].b_ = b_array[x+g].b_; /* { dg-warning "self-assignment detected" } */ + g = g; /* { dg-warning "assigned to itself" } */ + y = y; /* { dg-warning "assigned to itself" } */ + bar->b_ = bar->b_; /* { dg-warning "assigned to itself" } */ +} diff --git a/gcc/testsuite/gcc.dg/plugin/self-assign-test-2.c b/gcc/testsuite/gcc.dg/plugin/self-assign-test-2.c new file mode 100644 index 00000000000..2ede371a69a --- /dev/null +++ b/gcc/testsuite/gcc.dg/plugin/self-assign-test-2.c @@ -0,0 +1,23 @@ +/* Test the self-assignemnt detection plugin with the 'disable' argument. */ +/* { dg-do compile } */ +/* { dg-options "-O -fplugin-arg-selfassign-disable" } */ + +struct Bar { + int b_; + int c_; +}; + +int g; + +int main() +{ + struct Bar *bar; + int x = x; /* { dg-bogus "assigned to itself" } */ + static int y; + struct Bar b_array[5]; + + b_array[x+g].b_ = b_array[x+g].b_; /* { dg-bogus "self-assignment detected" } */ + g = g; /* { dg-bogus "assigned to itself" } */ + y = y; /* { dg-bogus "assigned to itself" } */ + bar->b_ = bar->b_; /* { dg-bogus "assigned to itself" } */ +} diff --git a/gcc/testsuite/gcc.dg/plugin/selfassign.c b/gcc/testsuite/gcc.dg/plugin/selfassign.c new file mode 100644 index 00000000000..6fbce83c01d --- /dev/null +++ b/gcc/testsuite/gcc.dg/plugin/selfassign.c @@ -0,0 +1,365 @@ +/* This plugin contains an analysis pass that detects and warns about + self-assignment statements. */ +/* { dg-options "-O" } */ + +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "tm.h" +#include "toplev.h" +#include "basic-block.h" +#include "gimple.h" +#include "tree.h" +#include "tree-pass.h" +#include "intl.h" +#include "gcc-plugin.h" + + +/* Indicate whether to check overloaded operator '=', which is performed by + default. To disable it, use -fplugin-arg-NAME-no-check-operator-eq. */ +bool check_operator_eq = true; + +/* Given a rhs EXPR of a gimple assign statement, if it is + - SSA_NAME : returns its var decl, or, if it is a temp variable, + returns the rhs of its SSA def statement. + - VAR_DECL, PARM_DECL, FIELD_DECL, or a reference expression : + returns EXPR itself. + - any other expression : returns NULL_TREE. */ + +static tree +get_real_ref_rhs (tree expr) +{ + switch (TREE_CODE (expr)) + { + case SSA_NAME: + { + /* Given a self-assign statement, say foo.x = foo.x, + the IR (after SSA) looks like: + + D.1797_14 = foo.x; + foo.x ={v} D.1797_14; + + So if the rhs EXPR is an SSA_NAME of a temp variable, + e.g. D.1797_14, we need to grab the rhs of its SSA def + statement (i.e. foo.x). */ + tree vdecl = SSA_NAME_VAR (expr); + if (DECL_ARTIFICIAL (vdecl) + && !gimple_nop_p (SSA_NAME_DEF_STMT (expr))) + { + gimple def_stmt = SSA_NAME_DEF_STMT (expr); + /* We are only interested in an assignment with a single + rhs operand because if it is not, the original assignment + will not possibly be a self-assignment. */ + if (is_gimple_assign (def_stmt) + && (get_gimple_rhs_class (gimple_assign_rhs_code (def_stmt)) + == GIMPLE_SINGLE_RHS)) + return get_real_ref_rhs (gimple_assign_rhs1 (def_stmt)); + else + return NULL_TREE; + } + else + return vdecl; + } + case VAR_DECL: + case PARM_DECL: + case FIELD_DECL: + case COMPONENT_REF: + case INDIRECT_REF: + case ARRAY_REF: + return expr; + default: + return NULL_TREE; + } +} + +/* Given an expression tree, EXPR, that may contains SSA names, returns an + equivalent tree with the SSA names converted to var/parm/field decls + so that it can be used with '%E' format modifier when emitting warning + messages. + + This function currently only supports VAR/PARM/FIELD_DECL, reference + expressions (COMPONENT_REF, INDIRECT_REF, ARRAY_REF), integer constant, + and SSA_NAME. If EXPR contains any other tree nodes (e.g. an arithmetic + expression appears in array index), NULL_TREE is returned. */ + +static tree +get_non_ssa_expr (tree expr) +{ + switch (TREE_CODE (expr)) + { + case VAR_DECL: + case PARM_DECL: + case FIELD_DECL: + { + if (DECL_NAME (expr)) + return expr; + else + return NULL_TREE; + } + case COMPONENT_REF: + { + tree base, orig_base = TREE_OPERAND (expr, 0); + tree component, orig_component = TREE_OPERAND (expr, 1); + base = get_non_ssa_expr (orig_base); + if (!base) + return NULL_TREE; + component = get_non_ssa_expr (orig_component); + if (!component) + return NULL_TREE; + /* If either BASE or COMPONENT is converted, build a new + component reference tree. */ + if (base != orig_base || component != orig_component) + return build3 (COMPONENT_REF, TREE_TYPE (component), + base, component, NULL_TREE); + else + return expr; + } + case INDIRECT_REF: + { + tree orig_base = TREE_OPERAND (expr, 0); + tree base = get_non_ssa_expr (orig_base); + if (!base) + return NULL_TREE; + /* If BASE is converted, build a new indirect reference tree. */ + if (base != orig_base) + return build1 (INDIRECT_REF, TREE_TYPE (TREE_TYPE (base)), base); + else + return expr; + } + case ARRAY_REF: + { + tree array, orig_array = TREE_OPERAND (expr, 0); + tree index, orig_index = TREE_OPERAND (expr, 1); + array = get_non_ssa_expr (orig_array); + if (!array) + return NULL_TREE; + index = get_non_ssa_expr (orig_index); + if (!index) + return NULL_TREE; + /* If either ARRAY or INDEX is converted, build a new array + reference tree. */ + if (array != orig_array || index != orig_index) + return build4 (ARRAY_REF, TREE_TYPE (expr), array, index, + TREE_OPERAND (expr, 2), TREE_OPERAND (expr, 3)); + else + return expr; + } + case SSA_NAME: + { + tree vdecl = SSA_NAME_VAR (expr); + if (DECL_ARTIFICIAL (vdecl) + && !gimple_nop_p (SSA_NAME_DEF_STMT (expr))) + { + gimple def_stmt = SSA_NAME_DEF_STMT (expr); + if (is_gimple_assign (def_stmt) + && (get_gimple_rhs_class (gimple_assign_rhs_code (def_stmt)) + == GIMPLE_SINGLE_RHS)) + vdecl = gimple_assign_rhs1 (def_stmt); + } + return get_non_ssa_expr (vdecl); + } + case INTEGER_CST: + return expr; + default: + /* Return NULL_TREE for any other kind of tree nodes. */ + return NULL_TREE; + } +} + +/* Given the LHS and (real) RHS of a gimple assign statement, STMT, check if + they are the same. If so, print a warning message about self-assignment. */ + +static void +compare_and_warn (gimple stmt, tree lhs, tree rhs) +{ + if (operand_equal_p (lhs, rhs, OEP_PURE_SAME)) + { + location_t location; + location = (gimple_has_location (stmt) + ? gimple_location (stmt) + : (DECL_P (lhs) + ? DECL_SOURCE_LOCATION (lhs) + : input_location)); + /* If LHS contains any tree node not currently supported by + get_non_ssa_expr, simply emit a generic warning without + specifying LHS in the message. */ + lhs = get_non_ssa_expr (lhs); + if (lhs) + warning (0, G_("%H%qE is assigned to itself"), &location, lhs); + else + warning (0, G_("%Hself-assignment detected"), &location); + } +} + +/* Check and warn if STMT is a self-assign statement. */ + +static void +warn_self_assign (gimple stmt) +{ + tree rhs, lhs; + + /* Check assigment statement. */ + if (is_gimple_assign (stmt) + && (get_gimple_rhs_class (gimple_assign_rhs_code (stmt)) + == GIMPLE_SINGLE_RHS)) + { + rhs = get_real_ref_rhs (gimple_assign_rhs1 (stmt)); + if (!rhs) + return; + + lhs = gimple_assign_lhs (stmt); + if (TREE_CODE (lhs) == SSA_NAME) + { + lhs = SSA_NAME_VAR (lhs); + if (DECL_ARTIFICIAL (lhs)) + return; + } + + compare_and_warn (stmt, lhs, rhs); + } + /* Check overloaded operator '=' (if enabled). */ + else if (check_operator_eq && is_gimple_call (stmt)) + { + tree fdecl = gimple_call_fndecl (stmt); + if (fdecl && (DECL_NAME (fdecl) == maybe_get_identifier ("operator="))) + { + /* If 'operator=' takes reference operands, the arguments will be + ADDR_EXPR trees. In this case, just remove the address-taken + operator before we compare the lhs and rhs. */ + lhs = gimple_call_arg (stmt, 0); + if (TREE_CODE (lhs) == ADDR_EXPR) + lhs = TREE_OPERAND (lhs, 0); + rhs = gimple_call_arg (stmt, 1); + if (TREE_CODE (rhs) == ADDR_EXPR) + rhs = TREE_OPERAND (rhs, 0); + + compare_and_warn (stmt, lhs, rhs); + } + } +} + +/* Entry point for the self-assignment detection pass. */ + +static unsigned int +execute_warn_self_assign (void) +{ + gimple_stmt_iterator gsi; + basic_block bb; + + FOR_EACH_BB (bb) + { + for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) + warn_self_assign (gsi_stmt (gsi)); + } + + return 0; +} + +/* Pass gate function. Currently always returns true. */ + +static bool +gate_warn_self_assign (void) +{ + return true; +} + +static struct gimple_opt_pass pass_warn_self_assign = +{ + { + GIMPLE_PASS, + "warn_self_assign", /* name */ + gate_warn_self_assign, /* gate */ + execute_warn_self_assign, /* execute */ + NULL, /* sub */ + NULL, /* next */ + 0, /* static_pass_number */ + 0, /* tv_id */ + PROP_ssa, /* properties_required */ + 0, /* properties_provided */ + 0, /* properties_destroyed */ + 0, /* todo_flags_start */ + TODO_dump_func /* todo_flags_finish */ + } +}; + +/* The initialization routine exposed to and called by GCC. The spec of this + function is defined in gcc/gcc-plugin.h. + + PLUGIN_NAME - name of the plugin (useful for error reporting) + ARGC - the size of the ARGV array + ARGV - an array of key-value argument pair + + Returns 0 if initialization finishes successfully. + + Note that this function needs to be named exactly "plugin_init". */ + +int +plugin_init (const char *plugin_name, struct plugin_gcc_version *version, + int argc, struct plugin_argument *argv) +{ + struct plugin_pass pass_info; + bool enabled = true; + int i; + + if (!plugin_default_version_check (version, version)) + return 1; + + /* Self-assign detection should happen after SSA is constructed. */ + pass_info.pass = &pass_warn_self_assign.pass; + pass_info.reference_pass_name = "ssa"; + pass_info.ref_pass_instance_number = 1; + pass_info.pos_op = PASS_POS_INSERT_AFTER; + + /* Process the plugin arguments. This plugin takes the following arguments: + check-operator-eq, no-check-operator-eq, enable, and disable. + By default, the analysis is enabled with 'operator=' checked. */ + for (i = 0; i < argc; ++i) + { + if (!strcmp (argv[i].key, "check-operator-eq")) + { + if (argv[i].value) + warning (0, G_("option '-fplugin-arg-%s-check-operator-eq=%s'" + " ignored (superfluous '=%s')"), + plugin_name, argv[i].value, argv[i].value); + else + check_operator_eq = true; + } + else if (!strcmp (argv[i].key, "no-check-operator-eq")) + { + if (argv[i].value) + warning (0, G_("option '-fplugin-arg-%s-no-check-operator-eq=%s'" + " ignored (superfluous '=%s')"), + plugin_name, argv[i].value, argv[i].value); + else + check_operator_eq = false; + } + else if (!strcmp (argv[i].key, "enable")) + { + if (argv[i].value) + warning (0, G_("option '-fplugin-arg-%s-enable=%s' ignored" + " (superfluous '=%s')"), + plugin_name, argv[i].value, argv[i].value); + else + enabled = true; + } + else if (!strcmp (argv[i].key, "disable")) + { + if (argv[i].value) + warning (0, G_("option '-fplugin-arg-%s-disable=%s' ignored" + " (superfluous '=%s')"), + plugin_name, argv[i].value, argv[i].value); + else + enabled = false; + } + else + warning (0, G_("plugin %qs: unrecognized argument %qs ignored"), + plugin_name, argv[i].key); + } + + /* Register this new pass with GCC if the analysis is enabled. */ + if (enabled) + register_callback (plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, + &pass_info); + + return 0; +} diff --git a/gcc/testsuite/gcc.dg/pr39666-1.c b/gcc/testsuite/gcc.dg/pr39666-1.c new file mode 100644 index 00000000000..f1ba499c331 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr39666-1.c @@ -0,0 +1,22 @@ +/* PR middle-end/39666 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wuninitialized" } */ + +int +foo (int i) +{ + int j; + switch (i) + { + case -__INT_MAX__ - 1 ... -1: + j = 6; + break; + case 0: + j = 5; + break; + case 1 ... __INT_MAX__: + j = 4; + break; + } + return j; +} diff --git a/gcc/testsuite/gcc.dg/pr39666-2.c b/gcc/testsuite/gcc.dg/pr39666-2.c new file mode 100644 index 00000000000..e4ef1d5d2b7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr39666-2.c @@ -0,0 +1,22 @@ +/* PR middle-end/39666 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wuninitialized" } */ + +int +foo (int i) +{ + int j; /* { dg-warning "may be used uninitialized" } */ + switch (i) + { + case -__INT_MAX__ - 1 ... -1: + j = 6; + break; + case 0: + j = 5; + break; + case 2 ... __INT_MAX__: + j = 4; + break; + } + return j; +} diff --git a/gcc/testsuite/gcc.dg/ucnid-10.c b/gcc/testsuite/gcc.dg/ucnid-10.c new file mode 100644 index 00000000000..39148108b33 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ucnid-10.c @@ -0,0 +1,8 @@ +/* Verify diagnostics for extended identifiers refer to UCNs (in the C + locale). Test #pragma pack diagnostics. */ +/* { dg-do compile { target *-*-linux* *-*-cygwin* powerpc*-*-eabi* } } */ +/* { dg-options "-std=gnu99 -fextended-identifiers" } */ + +#pragma pack(push) +#pragma pack(pop, \u00f3) /* { dg-warning "pop, \\\\U000000f3.*push, \\\\U000000f3" } */ +#pragma pack(\u00e7) /* { dg-warning "unknown action '\\\\U000000e7'" } */ diff --git a/gcc/testsuite/gcc.dg/ucnid-11.c b/gcc/testsuite/gcc.dg/ucnid-11.c new file mode 100644 index 00000000000..b4063306857 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ucnid-11.c @@ -0,0 +1,5 @@ +/* { dg-do run } */ +/* { dg-xfail-if "" { powerpc-ibm-aix* *-*-solaris2.* } { "*" } { "" } } */ +/* { dg-options "-std=c99 -fextended-identifiers -fdata-sections" } */ + +#include "ucnid-3.c" diff --git a/gcc/testsuite/gcc.dg/ucnid-12.c b/gcc/testsuite/gcc.dg/ucnid-12.c new file mode 100644 index 00000000000..6c8789236b0 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ucnid-12.c @@ -0,0 +1,5 @@ +/* { dg-do run } */ +/* { dg-xfail-if "" { powerpc-ibm-aix* *-*-solaris2.* } { "*" } { "" } } */ +/* { dg-options "-std=c99 -fextended-identifiers -ffunction-sections" } */ + +#include "ucnid-4.c" diff --git a/gcc/testsuite/gcc.dg/ucnid-13.c b/gcc/testsuite/gcc.dg/ucnid-13.c new file mode 100644 index 00000000000..8ec69fa3b93 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ucnid-13.c @@ -0,0 +1,13 @@ +/* Verify diagnostics for extended identifiers refer to UCNs (in the C + locale). Miscellaneous diagnostics. */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99 -fextended-identifiers -Wpacked" } */ + +int a __attribute__((\u00c0)); /* { dg-warning "'\\\\U000000c0' attribute directive ignored" } */ + +extern void \u00c1 (void) __attribute__((deprecated)); +void g (void) { \u00c1 (); } /* { dg-warning "'\\\\U000000c1' is deprecated" } */ + +struct \u00c2 { char c; } __attribute__((packed)); /* { dg-warning "'\\\\U000000c2'" } */ + +void h (void) { asm ("%[\u00c3]" : : ); } /* { dg-error "undefined named operand '\\\\U000000c3'" } */ diff --git a/gcc/testsuite/gcc.dg/ucnid-8.c b/gcc/testsuite/gcc.dg/ucnid-8.c new file mode 100644 index 00000000000..4ec3eeba29f --- /dev/null +++ b/gcc/testsuite/gcc.dg/ucnid-8.c @@ -0,0 +1,14 @@ +/* Verify diagnostics for extended identifiers refer to UCNs (in the C + locale). Further tests of C front-end diagnostics. */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99 -fextended-identifiers -Wvla" } */ + +int a __attribute__((__mode__(\u00e9))); /* { dg-error "unknown machine mode '\\\\U000000e9'" } */ +struct s1 { int \u00e9 : 0; }; /* { dg-error "zero width for bit-field '\\\\U000000e9'" } */ + +void f (int b) { int \u00e9[b]; } /* { dg-warning "variable length array '\\\\U000000e9'" } */ + +void g (static int \u00e9); /* { dg-error "storage class specified for parameter '\\\\U000000e9'" } */ + +struct s2 { int \u00e1; } \u00e9 = { { 0 } }; /* { dg-warning "braces around scalar initializer" } */ +/* { dg-warning "near initialization for '\\\\U000000e9\\.\\\\U000000e1'" "UCN diag" { target *-*-* } 13 } */ diff --git a/gcc/testsuite/gcc.dg/ucnid-9.c b/gcc/testsuite/gcc.dg/ucnid-9.c new file mode 100644 index 00000000000..c563b91106d --- /dev/null +++ b/gcc/testsuite/gcc.dg/ucnid-9.c @@ -0,0 +1,24 @@ +/* Test __func__ with extended identifiers and character set + conversions. */ +/* { dg-do run } */ +/* { dg-xfail-if "" { "powerpc-ibm-aix*" } { "*" } { "" } } */ +/* { dg-options "-std=c99 -fextended-identifiers -fexec-charset=ISO-8859-1" } */ +/* { dg-require-iconv "ISO-8859-1" } */ + +extern int strcmp (const char *, const char *); +extern void abort (void); +extern void exit (int); + +void +\u00e9 (void) +{ + if (strcmp (__func__, "\u00e9") != 0) + abort (); +} + +int +main (void) +{ + \u00e9 (); + exit (0); +} |