From b9692580cf29e9c0c9868f5a603afb09384a167d Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Fri, 11 Dec 2015 17:26:55 -0500 Subject: [PATCH 17/31] FIXME: mostly-working g++.dg/diagnostic/token-ranges.C (no code changes) --- gcc/testsuite/g++.dg/diagnostic/token-ranges.C | 91 ++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 gcc/testsuite/g++.dg/diagnostic/token-ranges.C diff --git a/gcc/testsuite/g++.dg/diagnostic/token-ranges.C b/gcc/testsuite/g++.dg/diagnostic/token-ranges.C new file mode 100644 index 0000000..7e396d5 --- /dev/null +++ b/gcc/testsuite/g++.dg/diagnostic/token-ranges.C @@ -0,0 +1,91 @@ +/* { dg-options "-fdiagnostics-show-caret -std=c++11 -Wpedantic" } */ + +/* Verify that various diagnostics show source code ranges. */ + +/* These ones merely use token ranges; they don't use tree ranges. */ + +void bad_namespace () { + namespace foo { // { dg-error "'namespace' definition is not allowed here" } + } +/* { dg-begin-multiline-output "" } + namespace foo { + ^~~~~~~~~ + { dg-end-multiline-output "" } */ +} + + +void fn_defn_with_attribute () + __attribute__((constructor (0))) // { dg-error "attributes are not allowed on a function-definition" } +{ + /* { dg-begin-multiline-output "" } + __attribute__((constructor (0))) + ^~~~~~~~~~~~~ + { dg-end-multiline-output "" } */ +} + +class foo {}; +class bar : public typename foo // { dg-error "keyword 'typename' not allowed outside of templates" } +{ +}; +/* { dg-begin-multiline-output "" } + class bar : public typename foo + ^~~~~~~~ + { dg-end-multiline-output "" } */ + + +// C++11 attributes + +void bogus_scoped_attribute [[foo::400]] (); // { dg-error "expected an identifier for the attribute name" } +/* { dg-begin-multiline-output "" } + void bogus_scoped_attribute [[foo::400]] (); + ^~~ + { dg-end-multiline-output "" } */ + +void meta_deprecation [[deprecated]] (); // { dg-warning "use 'gnu::deprecated'" } +/* { dg-begin-multiline-output "" } + void meta_deprecation [[deprecated]] (); + ^~~~~~~~~~ + { dg-end-multiline-output "" } */ + + +int foo() return bar {} // { dg-error "named return values are no longer supported" } +/* { dg-begin-multiline-output "" } + int foo() return bar {} + ^~~~~~ + { dg-end-multiline-output "" } */ + +template void foo(T) +{ + struct A + { + template struct B {} // { dg-error "local class" } + +/* { dg-begin-multiline-output "" } + template struct B {} + ^~~~~~~~ + { dg-end-multiline-output "" } */ + }; +} + +extern "C" { template void foo(T); } // { dg-error "C linkage" } +/* { dg-begin-multiline-output "" } + extern "C" { template void foo(T); } + ^~~~~~~~ + { dg-end-multiline-output "" } */ +// TODO: It would be nice to inform the user of the location of the +// relevant extern "C". + +void default_arg_of_this (void *ptr = this); // { dg-error "'this'" } +/* { dg-begin-multiline-output "" } + void default_arg_of_this (void *ptr = this); + ^~~~ + { dg-end-multiline-output "" } */ + +void template_inside_fn () +{ + int i = template < // { dg-error "cannot appear at block scope" } +/* { dg-begin-multiline-output "" } + int i = template < + ^~~~~~~~ + { dg-end-multiline-output "" } */ +} -- 1.8.5.3