]> granicus.if.org Git - clang/commitdiff
David Blaikie and Chandler would like us to diagnose
authorRichard Smith <richard-llvm@metafoo.co.uk>
Fri, 6 Jan 2012 02:30:50 +0000 (02:30 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Fri, 6 Jan 2012 02:30:50 +0000 (02:30 +0000)
  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

lib/Sema/SemaDecl.cpp
test/CXX/basic/basic.link/p9.cpp
test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p11.cpp
test/SemaCXX/condition.cpp
test/SemaCXX/decl-expr-ambiguity.cpp

index 3e9e66d55dcc70a09197c47f71f6b3122c9e790d..fecfce4d2d210052b247d63d2452ef219c43a463 100644 (file)
@@ -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)
index d8969ba1ba988ba050069201abac31f8fa9328d7..c895253c68fb6bb892d553efe3b0a141f36cc321 100644 (file)
@@ -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}}
 }
index 303df8d23043c687a2e4055e816c2a2dbeacd85d..b1dcf4d0154368234008b508467250a694a45fdf 100644 (file)
@@ -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}}
     }
   };
 }
index 099c11cb9eeeef9e8012ec9a89f1792960488f73..3d17dc39377e84ed1971098d158dba3a84937094 100644 (file)
@@ -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'}}
index 4a93b9ae71dc73b10757b4d2e29e1368d251a027..555e89ca7de2e3fbc3f4b91cb9aec15020455e65 100644 (file)
@@ -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);