[cfe-commits] r147649 - in /cfe/trunk: 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
Richard Smith
richard-llvm at metafoo.co.uk
Thu Jan 5 18:30:50 PST 2012
Author: rsmith
Date: Thu Jan 5 20:30:50 2012
New Revision: 147649
URL: http://llvm.org/viewvc/llvm-project?rev=147649&view=rev
Log:
David Blaikie and Chandler would like us to diagnose
int f();
in function scopes under -Wvexing-parse, so now we do.
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/CXX/basic/basic.link/p9.cpp
cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p11.cpp
cfe/trunk/test/SemaCXX/condition.cpp
cfe/trunk/test/SemaCXX/decl-expr-ambiguity.cpp
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=147649&r1=147648&r2=147649&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Thu Jan 5 20:30:50 2012
@@ -4914,8 +4914,7 @@
== 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)
Modified: cfe/trunk/test/CXX/basic/basic.link/p9.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/basic/basic.link/p9.cpp?rev=147649&r1=147648&r2=147649&view=diff
==============================================================================
--- cfe/trunk/test/CXX/basic/basic.link/p9.cpp (original)
+++ cfe/trunk/test/CXX/basic/basic.link/p9.cpp Thu Jan 5 20:30:50 2012
@@ -6,5 +6,5 @@
// 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}}
}
Modified: cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p11.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p11.cpp?rev=147649&r1=147648&r2=147649&view=diff
==============================================================================
--- cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p11.cpp (original)
+++ cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p11.cpp Thu Jan 5 20:30:50 2012
@@ -25,13 +25,13 @@
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 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 @@
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 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 @@
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}}
}
};
}
Modified: cfe/trunk/test/SemaCXX/condition.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/condition.cpp?rev=147649&r1=147648&r2=147649&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/condition.cpp (original)
+++ cfe/trunk/test/SemaCXX/condition.cpp Thu Jan 5 20:30:50 2012
@@ -7,7 +7,7 @@
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'}}
Modified: cfe/trunk/test/SemaCXX/decl-expr-ambiguity.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/decl-expr-ambiguity.cpp?rev=147649&r1=147648&r2=147649&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/decl-expr-ambiguity.cpp (original)
+++ cfe/trunk/test/SemaCXX/decl-expr-ambiguity.cpp Thu Jan 5 20:30:50 2012
@@ -26,13 +26,9 @@
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);
More information about the cfe-commits
mailing list