+2014-12-03 Paolo Carlini <paolo.carlini@oracle.com>
+
+ PR c++/63558
+ * decl.c (identify_goto): Return a bool if diagnostic is emitted.
+ (check_previous_goto_1): Consistently emit permerror + inform.
+ (check_goto): Likewise.
+
2014-12-03 Richard Biener <rguenther@suse.de>
* constexpr.c (cxx_eval_builtin_function_call): Use
/* A subroutine of check_previous_goto_1 to identify a branch to the user. */
-static void
+static bool
identify_goto (tree decl, const location_t *locus)
{
- if (decl)
- permerror (input_location, "jump to label %qD", decl);
- else
- permerror (input_location, "jump to case label");
- if (locus)
- permerror (*locus, " from here");
+ bool complained = (decl
+ ? permerror (input_location, "jump to label %qD", decl)
+ : permerror (input_location, "jump to case label"));
+ if (complained && locus)
+ inform (*locus, " from here");
+ return complained;
}
/* Check that a single previously seen jump to a newly defined label
bool exited_omp, const location_t *locus)
{
cp_binding_level *b;
- bool identified = false, saw_eh = false, saw_omp = false;
+ bool identified = false, complained = false;
+ bool saw_eh = false, saw_omp = false;
if (exited_omp)
{
- identify_goto (decl, locus);
- error (" exits OpenMP structured block");
+ complained = identify_goto (decl, locus);
+ if (complained)
+ inform (input_location, " exits OpenMP structured block");
identified = saw_omp = true;
}
if (!identified)
{
- identify_goto (decl, locus);
+ complained = identify_goto (decl, locus);
identified = true;
}
- if (problem > 1)
- error (" crosses initialization of %q+#D", new_decls);
- else
- permerror (input_location, " enters scope of %q+#D which has "
- "non-trivial destructor", new_decls);
+ if (complained)
+ {
+ if (problem > 1)
+ inform (input_location,
+ " crosses initialization of %q+#D", new_decls);
+ else
+ inform (input_location, " enters scope of %q+#D which has "
+ "non-trivial destructor", new_decls);
+ }
}
if (b == level)
{
if (!identified)
{
- identify_goto (decl, locus);
+ complained = identify_goto (decl, locus);
identified = true;
}
- if (b->kind == sk_try)
- error (" enters try block");
- else
- error (" enters catch block");
+ if (complained)
+ {
+ if (b->kind == sk_try)
+ inform (input_location, " enters try block");
+ else
+ inform (input_location, " enters catch block");
+ }
saw_eh = true;
}
if (b->kind == sk_omp && !saw_omp)
{
if (!identified)
{
- identify_goto (decl, locus);
+ complained = identify_goto (decl, locus);
identified = true;
}
- error (" enters OpenMP structured block");
+ if (complained)
+ inform (input_location, " enters OpenMP structured block");
saw_omp = true;
}
}
check_goto (tree decl)
{
struct named_label_entry *ent, dummy;
- bool saw_catch = false, identified = false;
+ bool saw_catch = false, identified = false, complained = false;
tree bad;
unsigned ix;
if (ent->in_try_scope || ent->in_catch_scope
|| ent->in_omp_scope || !vec_safe_is_empty (ent->bad_decls))
{
- permerror (input_location, "jump to label %q+D", decl);
- permerror (input_location, " from here");
+ complained = permerror (input_location, "jump to label %q+D", decl);
+ if (complained)
+ inform (input_location, " from here");
identified = true;
}
if (u > 1 && DECL_ARTIFICIAL (bad))
{
/* Can't skip init of __exception_info. */
- error_at (DECL_SOURCE_LOCATION (bad), " enters catch block");
+ if (complained)
+ inform (DECL_SOURCE_LOCATION (bad), " enters catch block");
saw_catch = true;
}
- else if (u > 1)
- error (" skips initialization of %q+#D", bad);
- else
- permerror (input_location, " enters scope of %q+#D which has "
- "non-trivial destructor", bad);
+ else if (complained)
+ {
+ if (u > 1)
+ inform (input_location, " skips initialization of %q+#D", bad);
+ else
+ inform (input_location, " enters scope of %q+#D which has "
+ "non-trivial destructor", bad);
+ }
}
- if (ent->in_try_scope)
- error (" enters try block");
- else if (ent->in_catch_scope && !saw_catch)
- error (" enters catch block");
+ if (complained)
+ {
+ if (ent->in_try_scope)
+ inform (input_location, " enters try block");
+ else if (ent->in_catch_scope && !saw_catch)
+ inform (input_location, " enters catch block");
+ }
if (ent->in_omp_scope)
- error (" enters OpenMP structured block");
+ {
+ if (complained)
+ inform (input_location, " enters OpenMP structured block");
+ }
else if (flag_openmp)
{
cp_binding_level *b;
{
if (!identified)
{
- permerror (input_location, "jump to label %q+D", decl);
- permerror (input_location, " from here");
+ complained = permerror (input_location,
+ "jump to label %q+D", decl);
+ if (complained)
+ inform (input_location, " from here");
identified = true;
}
- error (" exits OpenMP structured block");
+ if (complained)
+ inform (input_location, " exits OpenMP structured block");
break;
}
}
+2014-12-03 Paolo Carlini <paolo.carlini@oracle.com>
+
+ PR c++/63558
+ * g++.dg/init/goto3.C: New.
+ * g++.dg/eh/goto2.C: Adjust.
+ * g++.dg/ext/vla14.C: Likewise.
+ * g++.dg/gomp/block-1.C: Likewise.
+ * g++.dg/gomp/block-2.C: Likewise.
+ * g++.dg/gomp/block-3.C: Likewise.
+ * g++.dg/gomp/block-5.C: Likewise.
+ * g++.dg/gomp/target-1.C: Likewise.
+ * g++.dg/gomp/target-2.C: Likewise.
+ * g++.dg/gomp/taskgroup-1.C: Likewise.
+ * g++.dg/gomp/teams-1.C: Likewise.
+ * g++.dg/init/goto2.C: Likewise.
+ * g++.dg/warn/pedantic1.C: Likewise.
+ * g++.old-deja/g++.jason/jump.C: Likewise.
+ * g++.old-deja/g++.law/arm6.C: Likewise.
+ * g++.old-deja/g++.other/goto1.C: Likewise.
+ * g++.old-deja/g++.other/goto3.C: Likewise.
+ * g++.old-deja/g++.other/init9.C: Likewise.
+
2014-12-03 Michael Meissner <meissner@linux.vnet.ibm.com>
PR target/64019
void f()
try
{
- goto l2; // { dg-error "from here" }
+ goto l2; // { dg-message "from here" }
l1: ; // { dg-error "jump to label 'l1'" }
} catch (...)
{
- l2: ; // { dg-error "jump to label 'l2'|enters catch block" }
- goto l1; // { dg-error "from here|enters try block" }
+ l2: ; // { dg-error "jump to label 'l2'" }
+ // { dg-message "enters catch block" "" { target *-*-*} 10 }
+ goto l1; // { dg-message "from here|enters try block" }
}
void
f (int n)
{
- goto label; // { dg-error "from here" }
- int a[n]; // { dg-error "crosses initialization" }
+ goto label; // { dg-message "from here" }
+ int a[n]; // { dg-message "crosses initialization" }
label: // { dg-error "jump to label" }
;
}
switch (1)
{
case 1:
- int (*a)[n]; // { dg-error "crosses initialization" }
+ int (*a)[n]; // { dg-message "crosses initialization" }
default: // { dg-error "jump to case label" }
;
}
{
bad1: // { dg-error "jump to label" }
#pragma omp parallel
- goto bad1; // { dg-error "from here|exits OpenMP" }
+ goto bad1; // { dg-message "from here|exits OpenMP" }
- goto bad2; // { dg-error "from here" }
+ goto bad2; // { dg-message "from here" }
#pragma omp parallel
{
- bad2: ; // { dg-error "jump to label|enters OpenMP" }
+ bad2: ; // { dg-error "jump to label" }
+ // { dg-message "enters OpenMP" "" { target *-*-* } 12 }
}
#pragma omp parallel
bad1: // { dg-error "jump to label" }
#pragma omp for
for (i = 0; i < 10; ++i)
- goto bad1; // { dg-error "from here|exits OpenMP" }
+ goto bad1; // { dg-message "from here|exits OpenMP" }
- goto bad2; // { dg-error "from here" }
+ goto bad2; // { dg-message "from here" }
#pragma omp for
for (i = 0; i < 10; ++i)
{
- bad2: ; // { dg-error "jump|enters OpenMP" }
+ bad2: ; // { dg-error "jump" }
+ // { dg-message "enters OpenMP" "" { target *-*-* } 20 }
}
#pragma omp for
#pragma omp section
{ bad1: ; } // { dg-error "jump to label" }
#pragma omp section
- goto bad1; // { dg-error "from here|enters OpenMP" }
+ goto bad1; // { dg-message "from here|enters OpenMP" }
}
#pragma omp sections
{
- goto bad2; // { dg-error "from here" }
+ goto bad2; // { dg-message "from here" }
}
- bad2:; // { dg-error "jump|exits OpenMP" }
+ bad2:; // { dg-error "jump" }
+ // { dg-message "exits OpenMP" "" { target *-*-* } 28 }
- goto bad3; // { dg-error "from here" }
+ goto bad3; // { dg-message "from here" }
#pragma omp sections
{
- bad3: ; // { dg-error "jump|enters OpenMP" }
+ bad3: ; // { dg-error "jump" }
+ // { dg-message "enters OpenMP" "" { target *-*-* } 34 }
}
#pragma omp sections
// { dg-message "error: invalid branch to/from an OpenMP structured block" "" { target *-*-* } 21 }
// { dg-message "error: invalid branch to/from an OpenMP structured block" "" { target *-*-* } 26 }
-// { dg-message "error: invalid entry to OpenMP structured block" "" { target *-*-* } 30 }
+// { dg-message "error: invalid entry to OpenMP structured block" "" { target *-*-* } 31 }
{
#pragma omp master
{
- goto bad1; // { dg-error "from here" }
+ goto bad1; // { dg-message "from here" }
}
#pragma omp master
{
- bad1: // { dg-error "jump|exits OpenMP" }
+ bad1: // { dg-error "jump" }
+ // { dg-message "exits OpenMP" "" { target *-*-* } 12 }
return; // { dg-error "invalid exit" }
}
}
{
bad1: // { dg-error "jump to label" }
#pragma omp target
- goto bad1; // { dg-error "from here|exits OpenMP" }
+ goto bad1; // { dg-message "from here|exits OpenMP" }
- goto bad2; // { dg-error "from here" }
+ goto bad2; // { dg-message "from here" }
#pragma omp target
{
- bad2: ; // { dg-error "jump to label|enters OpenMP" }
+ bad2: ; // { dg-error "jump to label" }
+ // { dg-message "enters OpenMP" "" { target *-*-* } 13 }
}
#pragma omp target
switch (x)
{
#pragma omp target
- { case 0:; } // { dg-error "jump|enters" }
+ { case 0:; } // { dg-error "jump" }
+ // { dg-message "enters" "" { target *-*-* } 28 }
}
}
{
bad1: // { dg-error "jump to label" }
#pragma omp target data map(tofrom: y)
- goto bad1; // { dg-error "from here|exits OpenMP" }
+ goto bad1; // { dg-message "from here|exits OpenMP" }
- goto bad2; // { dg-error "from here" }
+ goto bad2; // { dg-message "from here" }
#pragma omp target data map(tofrom: y)
{
- bad2: ; // { dg-error "jump to label|enters OpenMP" }
+ bad2: ; // { dg-error "jump to label" }
+ // { dg-message "enters OpenMP" "" { target *-*-* } 13 }
}
#pragma omp target data map(tofrom: y)
switch (x)
{
#pragma omp target data map(tofrom: y)
- { case 0:; } // { dg-error "jump|enters" }
+ { case 0:; } // { dg-error "jump" }
+ // { dg-message "enters" "" { target *-*-* } 28 }
}
}
{
bad1: // { dg-error "jump to label" }
#pragma omp taskgroup
- goto bad1; // { dg-error "from here|exits OpenMP" }
+ goto bad1; // { dg-message "from here|exits OpenMP" }
- goto bad2; // { dg-error "from here" }
+ goto bad2; // { dg-message "from here" }
#pragma omp taskgroup
{
- bad2: ; // { dg-error "jump to label|enters OpenMP" }
+ bad2: ; // { dg-error "jump to label" }
+ // { dg-message "enters OpenMP" "" { target *-*-* } 13 }
}
#pragma omp taskgroup
switch (x)
{
#pragma omp taskgroup
- { case 0:; } // { dg-error "jump|enters" }
+ { case 0:; } // { dg-error "jump" }
+ // { dg-message "enters" "" { target *-*-* } 28 }
}
}
{
bad1: // { dg-error "jump to label" }
#pragma omp target teams
- goto bad1; // { dg-error "from here|exits OpenMP" }
+ goto bad1; // { dg-message "from here|exits OpenMP" }
- goto bad2; // { dg-error "from here" }
+ goto bad2; // { dg-message "from here" }
#pragma omp target teams
{
- bad2: ; // { dg-error "jump to label|enters OpenMP" }
+ bad2: ; // { dg-error "jump to label" }
+ // { dg-message "enters OpenMP" "" { target *-*-* } 13 }
}
#pragma omp target teams
switch (x)
{
#pragma omp target teams
- { case 0:; } // { dg-error "jump|enters" }
+ { case 0:; } // { dg-error "jump" }
+ // { dg-message "enters" "" { target *-*-* } 28 }
}
}
bad1: // { dg-error "jump to label" }
#pragma omp target
#pragma omp teams
- goto bad1; // { dg-error "from here|exits OpenMP" }
+ goto bad1; // { dg-message "from here|exits OpenMP" }
- goto bad2; // { dg-error "from here" }
+ goto bad2; // { dg-message "from here" }
#pragma omp target
#pragma omp teams
{
- bad2: ; // { dg-error "jump to label|enters OpenMP" }
+ bad2: ; // { dg-error "jump to label" }
+ // { dg-message "enters OpenMP" "" { target *-*-* } 45 }
}
#pragma omp target
{
#pragma omp target
#pragma omp teams
- { case 0:; } // { dg-error "jump|enters" }
+ { case 0:; } // { dg-error "jump" }
+ // { dg-message "enters" "" { target *-*-* } 62 }
}
}
// { dg-error "invalid branch to/from an OpenMP structured block" "" { target *-*-* } 8 }
// { dg-error "invalid entry to OpenMP structured block" "" { target *-*-* } 10 }
-// { dg-error "invalid branch to/from an OpenMP structured block" "" { target *-*-* } 37 }
-// { dg-error "invalid entry to OpenMP structured block" "" { target *-*-* } 39 }
+// { dg-error "invalid branch to/from an OpenMP structured block" "" { target *-*-* } 39 }
+// { dg-error "invalid entry to OpenMP structured block" "" { target *-*-* } 41 }
bool f();
void g(int i)
{
- if (i) goto bad; // { dg-error "from" }
- bool a = f(); // { dg-error "initialization" }
+ if (i) goto bad; // { dg-message "from" }
+ bool a = f(); // { dg-message "initialization" }
bad: // { dg-error "jump" }
;
}
--- /dev/null
+// PR c++/63558
+// { dg-options "-fpermissive -w" }
+
+extern int abs(int);
+static long int n_ants;
+enum enum_var_types
+ { VAR_NONE, VAR_DELTA, VAR_SWITCH };
+
+static enum enum_var_types option_var_n_ants;
+void
+adapt_parameters_next_iteration(void)
+{
+ switch(option_var_n_ants) {
+
+ case VAR_NONE: break;
+
+ case VAR_DELTA:
+ int trunc_n_ants = 0;
+ n_ants += trunc_n_ants;
+ break;
+ case VAR_SWITCH:
+ break;
+ default: break;
+ }
+}
// { dg-options "-pedantic" }
int main() {
- goto label; // { dg-error "" }
+ goto label; // { dg-message "" }
- int temp = 1; // { dg-error "" }
+ int temp = 1; // { dg-message "" }
label: // { dg-error "" }
return 1;
int main() {
switch (a) {
case 1:
- int v2 = 3; // { dg-error "" } referenced below
+ int v2 = 3; // { dg-message "" } referenced below
case 2: // { dg-error "" } jumping past initializer
if (v2 == 7)
;
switch (a) {
case 1:
- int v2 = 3;// { dg-error "" } crosses.*
+ int v2 = 3;// { dg-message "" } crosses.*
case 2:// { dg-error "" } jump.*
if (v2 == 7) // error not flagged by 2.3.1
;
void f ()
{
{
- S s1; // { dg-error "" } skips initialization
+ S s1; // { dg-message "" } skips initialization
t: // { dg-error "" } jump to label
S s2;
;
}
- goto t; // { dg-error "" } from here
+ goto t; // { dg-message "" } from here
}
void f ()
{
- goto foo1; // { dg-error "" } jumps
+ goto foo1; // { dg-message "" } jumps
try { foo1:; } catch (...) { } // { dg-error "" } into try
- goto foo2; // { dg-error "" } jumps
+ goto foo2; // { dg-message "" } jumps
try { } catch (...) { foo2:; } // { dg-error "" } into catch
- goto foo3; // { dg-error "" } jumps
+ goto foo3; // { dg-message "" } jumps
{ int i=2; foo3:; } // { dg-error "" } past init
try { foo4:; } catch (...) { } // { dg-error "" }
- goto foo4; // { dg-error "" }
+ goto foo4; // { dg-message "" }
try { } catch (...) { foo5:; } // { dg-error "" }
- goto foo5; // { dg-error "" }
+ goto foo5; // { dg-message "" }
{ int i=2; foo6:; } // { dg-error "" }
- goto foo6; // { dg-error "" }
+ goto foo6; // { dg-message "" }
}
};
void a() {
- goto bar; // { dg-error "" } jump from here
- A x; // { dg-error "" } jump crosses initialization
+ goto bar; // { dg-message "" } jump from here
+ A x; // { dg-message "" } jump crosses initialization
bar: // { dg-error "" } jump to here
;
}
};
void b() {
- goto bar; // { dg-error "" } jump from here
- X x; // { dg-error "" } jump crosses initialization
+ goto bar; // { dg-message "" } jump from here
+ X x; // { dg-message "" } jump crosses initialization
bar: // { dg-error "" } jump to here
;
}
#include <vector>
void c() {
- goto bar; // { dg-error "" } jump from here
- std::vector<int> x; // { dg-error "" } jump crosses initialization
+ goto bar; // { dg-message "" } jump from here
+ std::vector<int> x; // { dg-message "" } jump crosses initialization
bar: // { dg-error "" } jump to here
;
}