diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-01-06 02:30:50 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-01-06 02:30:50 +0000 |
commit | 2f0e88a87cea6d21429d9f5c0b1c53f24caf77cf (patch) | |
tree | 9efd71d232f39957e0fbcd837097bb3d9ef69bce | |
parent | e0e7c99410f24777f7b10d6c651a262b93c4a8b3 (diff) |
David Blaikie and Chandler would like us to diagnose
int f();
in function scopes under -Wvexing-parse, so now we do.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147649 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 3 | ||||
-rw-r--r-- | test/CXX/basic/basic.link/p9.cpp | 2 | ||||
-rw-r--r-- | test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p11.cpp | 12 | ||||
-rw-r--r-- | test/SemaCXX/condition.cpp | 2 | ||||
-rw-r--r-- | test/SemaCXX/decl-expr-ambiguity.cpp | 10 |
5 files changed, 12 insertions, 17 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 3e9e66d55d..fecfce4d2d 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -4914,8 +4914,7 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, == DeclSpec::SCS_unspecified) { QualType T = R->getAs<FunctionType>()->getResultType(); DeclaratorChunk &C = D.getTypeObject(0); - if ((T->isDependentType() || T->isRecordType()) && - C.Fun.NumArgs == 0 && !C.Fun.isVariadic && + if (!T->isVoidType() && C.Fun.NumArgs == 0 && !C.Fun.isVariadic && !C.Fun.TrailingReturnType && C.Fun.getExceptionSpecType() == EST_None) { Diag(C.Loc, diag::warn_empty_parens_are_function_decl) diff --git a/test/CXX/basic/basic.link/p9.cpp b/test/CXX/basic/basic.link/p9.cpp index d8969ba1ba..c895253c68 100644 --- a/test/CXX/basic/basic.link/p9.cpp +++ b/test/CXX/basic/basic.link/p9.cpp @@ -6,5 +6,5 @@ namespace N { } // expected-note{{here}} // First bullet: two names with external linkage that refer to // different kinds of entities. void f() { - int N(); // expected-error{{redefinition}} + int N(); // expected-error{{redefinition}} expected-warning{{interpreted as a function declaration}} } diff --git a/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p11.cpp b/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p11.cpp index 303df8d230..b1dcf4d015 100644 --- a/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p11.cpp +++ b/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p11.cpp @@ -25,13 +25,13 @@ namespace test1 { namespace test2 { namespace ns { void foo(); } // expected-note 2 {{target of using declaration}} void test0() { - int foo(); // expected-note {{conflicting declaration}} + int foo(); // expected-note {{conflicting declaration}} expected-warning{{function declaration}} using ns::foo; // expected-error {{target of using declaration conflicts with declaration already in scope}} } void test1() { using ns::foo; //expected-note {{using declaration}} - int foo(); // expected-error {{declaration conflicts with target of using declaration already in scope}} + int foo(); // expected-error {{declaration conflicts with target of using declaration already in scope}} expected-warning{{function declaration}} } } @@ -39,7 +39,7 @@ namespace test3 { namespace ns { void foo(); } // expected-note 2 {{target of using declaration}} class Test0 { void test() { - int foo(); // expected-note {{conflicting declaration}} + int foo(); // expected-note {{conflicting declaration}} expected-warning{{function declaration}} using ns::foo; // expected-error {{target of using declaration conflicts with declaration already in scope}} } }; @@ -47,7 +47,7 @@ namespace test3 { class Test1 { void test() { using ns::foo; //expected-note {{using declaration}} - int foo(); // expected-error {{declaration conflicts with target of using declaration already in scope}} + int foo(); // expected-error {{declaration conflicts with target of using declaration already in scope}} expected-warning{{function declaration}} } }; } @@ -56,7 +56,7 @@ namespace test4 { namespace ns { void foo(); } // expected-note 2 {{target of using declaration}} template <typename> class Test0 { void test() { - int foo(); // expected-note {{conflicting declaration}} + int foo(); // expected-note {{conflicting declaration}} expected-warning{{function declaration}} using ns::foo; // expected-error {{target of using declaration conflicts with declaration already in scope}} } }; @@ -64,7 +64,7 @@ namespace test4 { template <typename> class Test1 { void test() { using ns::foo; //expected-note {{using declaration}} - int foo(); // expected-error {{declaration conflicts with target of using declaration already in scope}} + int foo(); // expected-error {{declaration conflicts with target of using declaration already in scope}} expected-warning{{function declaration}} } }; } diff --git a/test/SemaCXX/condition.cpp b/test/SemaCXX/condition.cpp index 099c11cb9e..3d17dc3937 100644 --- a/test/SemaCXX/condition.cpp +++ b/test/SemaCXX/condition.cpp @@ -7,7 +7,7 @@ void test() { typedef int arr[10]; while (arr x=0) ; // expected-error {{an array type is not allowed here}} expected-error {{array initializer must be an initializer list}} - while (int f()=0) ; // expected-error {{a function type is not allowed here}} + while (int f()=0) ; // expected-warning {{interpreted as a function declaration}} expected-error {{a function type is not allowed here}} struct S {} s; if (s) ++x; // expected-error {{value of type 'struct S' is not contextually convertible to 'bool'}} diff --git a/test/SemaCXX/decl-expr-ambiguity.cpp b/test/SemaCXX/decl-expr-ambiguity.cpp index 4a93b9ae71..555e89ca7d 100644 --- a/test/SemaCXX/decl-expr-ambiguity.cpp +++ b/test/SemaCXX/decl-expr-ambiguity.cpp @@ -26,13 +26,9 @@ void f() { T(*d)(int(p)); // expected-warning {{parentheses were disambiguated as a function declarator}} expected-note {{previous definition is here}} typedef T(*td)(int(p)); extern T(*tp)(int(p)); - S d3(); // expected-warning {{empty parentheses interpreted as a function declaration}} - S d3v(void); - typedef S d3t(); - extern S f3(); - __typeof(*T()) f4(); // expected-warning {{empty parentheses interpreted as a function declaration}} - S multi1, - multi2(); // expected-warning {{empty parentheses interpreted as a function declaration}} + T d3(); // expected-warning {{empty parentheses interpreted as a function declaration}} + typedef T d3t(); + extern T f3(); T(d)[5]; // expected-error {{redefinition of 'd'}} typeof(int[])(f) = { 1, 2 }; // expected-error {{extension used}} void(b)(int); |