summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/Sema/SemaType.cpp7
-rw-r--r--clang/test/Parser/cxx-decl.cpp16
-rw-r--r--clang/test/SemaCXX/decl-expr-ambiguity.cpp17
3 files changed, 39 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index b45d31c6b1e..63a4963946e 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -3165,7 +3165,12 @@ static void warnAboutRedundantParens(Sema &S, Declarator &D, QualType T) {
// In a new-type-id, function chunks require parentheses.
if (D.getContext() == Declarator::CXXNewContext)
return;
- LLVM_FALLTHROUGH;
+ // FIXME: "A(f())" deserves a vexing-parse warning, not just a
+ // redundant-parens warning, but we don't know whether the function
+ // chunk was syntactically valid as an expression here.
+ CouldBeTemporaryObject = false;
+ continue;
+
case DeclaratorChunk::BlockPointer:
case DeclaratorChunk::MemberPointer:
case DeclaratorChunk::Pipe:
diff --git a/clang/test/Parser/cxx-decl.cpp b/clang/test/Parser/cxx-decl.cpp
index 711a874f6a2..58ad08079c1 100644
--- a/clang/test/Parser/cxx-decl.cpp
+++ b/clang/test/Parser/cxx-decl.cpp
@@ -282,6 +282,22 @@ namespace NNS {
}
}
+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}}
diff --git a/clang/test/SemaCXX/decl-expr-ambiguity.cpp b/clang/test/SemaCXX/decl-expr-ambiguity.cpp
index 1e31d701d0c..b77e226b5d0 100644
--- a/clang/test/SemaCXX/decl-expr-ambiguity.cpp
+++ b/clang/test/SemaCXX/decl-expr-ambiguity.cpp
@@ -125,3 +125,20 @@ void fizbin() {
baz b3; // expected-error {{must use 'class' tag to refer to type 'baz' in this scope}}
}
}
+
+namespace TemporaryFromFunctionCall {
+ struct A {
+ A(int);
+ };
+ int f();
+ int g(int);
+ namespace N {
+ void x() {
+ // FIXME: For the first and second of these (but not the third), we
+ // should produce a vexing-parse warning.
+ A(f());
+ A(g(int()));
+ A(g(int));
+ }
+ }
+}
OpenPOWER on IntegriCloud