diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2017-12-24 01:00:23 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2017-12-24 01:00:23 +0000 |
| commit | 6252156da5066bd47f63f8bd40404d1f89909d32 (patch) | |
| tree | 743d1b59945b071890dc19b6bf5e9d3ff0d1399b /test/Parser/cxx-decl.cpp | |
| parent | 461a67fa15370a9ec88f8f8a240bf7c123bb2029 (diff) | |
Diffstat (limited to 'test/Parser/cxx-decl.cpp')
| -rw-r--r-- | test/Parser/cxx-decl.cpp | 43 |
1 files changed, 39 insertions, 4 deletions
diff --git a/test/Parser/cxx-decl.cpp b/test/Parser/cxx-decl.cpp index 8a7a388605392..58ad08079c1da 100644 --- a/test/Parser/cxx-decl.cpp +++ b/test/Parser/cxx-decl.cpp @@ -1,6 +1,6 @@ -// RUN: %clang_cc1 -verify -fsyntax-only -triple i386-linux -pedantic-errors -fcxx-exceptions -fexceptions %s -// RUN: %clang_cc1 -verify -fsyntax-only -triple i386-linux -pedantic-errors -fcxx-exceptions -fexceptions -std=c++98 %s -// RUN: %clang_cc1 -verify -fsyntax-only -triple i386-linux -pedantic-errors -fcxx-exceptions -fexceptions -std=c++11 %s +// RUN: %clang_cc1 -verify -fsyntax-only -triple i386-linux -Wredundant-parens -pedantic-errors -fcxx-exceptions -fexceptions %s +// RUN: %clang_cc1 -verify -fsyntax-only -triple i386-linux -Wredundant-parens -pedantic-errors -fcxx-exceptions -fexceptions -std=c++98 %s +// RUN: %clang_cc1 -verify -fsyntax-only -triple i386-linux -Wredundant-parens -pedantic-errors -fcxx-exceptions -fexceptions -std=c++11 %s const char const *x10; // expected-error {{duplicate 'const' declaration specifier}} @@ -83,7 +83,7 @@ namespace Commas { int global1, __attribute__(()) global2, - (global5), + (global5), // expected-warning {{redundant parentheses surrounding declarator}} *global6, &global7 = global1, &&global8 = static_cast<int&&>(global1), @@ -263,6 +263,41 @@ namespace DuplicateFriend { }; } +namespace NNS { + struct A {}; + namespace B { extern A C1, C2, *C3, C4[], C5; } + // Do not produce a redundant parentheses warning here; removing these parens + // changes the meaning of the program. + A (::NNS::B::C1); + A (NNS::B::C2); // expected-warning {{redundant parentheses surrounding declarator}} + A (*::NNS::B::C3); // expected-warning {{redundant parentheses surrounding declarator}} + A (::NNS::B::C4[2]); + // Removing one of these sets of parentheses would be reasonable. + A ((::NNS::B::C5)); // expected-warning {{redundant parentheses surrounding declarator}} + + void f() { + // FIXME: A vexing-parse warning here would be useful. + A(::NNS::B::C1); // expected-error {{definition or redeclaration}} + A(NNS::B::C1); // expected-warning {{redundant paren}} expected-error {{definition or redeclaration}} + } +} + +inline namespace ParensAroundFriend { // expected-error 0-1{{C++11}} + struct A {}; + struct B { + static A C(); + }; + namespace X { + struct B {}; + struct D { + // No warning here: while this could be written as + // friend (::B::C)(); + // we do need parentheses *somewhere* here. + friend A (::B::C()); + }; + } +} + // PR8380 extern "" // expected-error {{unknown linkage language}} test6a { ;// expected-error {{C++ requires a type specifier for all declarations}} |
