[clang] be8e5fe - [clang][NFC] Tests showing the problems with some uses of NamedDecl::getDeclName in diagnostics, SemaExpr.cpp part
Bruno Ricci via cfe-commits
cfe-commits at lists.llvm.org
Sat Jul 18 12:46:07 PDT 2020
Author: Bruno Ricci
Date: 2020-07-18T20:39:16+01:00
New Revision: be8e5fee91b44522056f1e780cdc861427f8738f
URL: https://github.com/llvm/llvm-project/commit/be8e5fee91b44522056f1e780cdc861427f8738f
DIFF: https://github.com/llvm/llvm-project/commit/be8e5fee91b44522056f1e780cdc861427f8738f.diff
LOG: [clang][NFC] Tests showing the problems with some uses of NamedDecl::getDeclName in diagnostics, SemaExpr.cpp part
Added:
Modified:
clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p7.cpp
clang/test/SemaCXX/attr-unused.cpp
clang/test/SemaCXX/default2.cpp
clang/test/SemaCXX/incomplete-call.cpp
clang/test/SemaCXX/lambda-expressions.cpp
Removed:
################################################################################
diff --git a/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p7.cpp b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p7.cpp
index af2e7cf09ceb..52986faa4e85 100644
--- a/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p7.cpp
+++ b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p7.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify %s
void h() {
int i1 = 0;
@@ -16,4 +16,16 @@ void h() {
const int i4 = 0;
extern void h4(int x = sizeof(i4)); // ok, not odr-use
extern void h5(int x = decltype(i4 + 4)()); // ok, not odr-use
+
+ union {
+ int i5;
+ };
+
+ extern void h6(int = i5);
+ // expected-error at -1 {{default argument references local variable '' of enclosing function}}
+
+ struct S { int i; };
+ auto [x] = S();
+
+ extern void h7(int = x); // FIXME: reject
}
diff --git a/clang/test/SemaCXX/attr-unused.cpp b/clang/test/SemaCXX/attr-unused.cpp
index b74bc915ce07..e3878152eca9 100644
--- a/clang/test/SemaCXX/attr-unused.cpp
+++ b/clang/test/SemaCXX/attr-unused.cpp
@@ -3,7 +3,17 @@
namespace ns_unused { typedef int Int_unused __attribute__((unused)); }
namespace ns_not_unused { typedef int Int_not_unused; }
+template <typename T> class C;
+template <> class __attribute__((unused)) C<int> {};
+
void f() {
ns_not_unused::Int_not_unused i1; // expected-warning {{unused variable}}
ns_unused::Int_unused i0; // expected-warning {{'Int_unused' was marked unused but was used}}
+
+ union __attribute__((unused)) { // expected-warning {{'' was marked unused but was used}}
+ int i;
+ };
+ (void) i;
+
+ C<int>(); // expected-warning {{'C' was marked unused but was used}}
}
diff --git a/clang/test/SemaCXX/default2.cpp b/clang/test/SemaCXX/default2.cpp
index 4c8e8ce6941a..7651233f8636 100644
--- a/clang/test/SemaCXX/default2.cpp
+++ b/clang/test/SemaCXX/default2.cpp
@@ -117,6 +117,12 @@ class C2 {
static int f(int = 10); // expected-note{{default argument declared here}}
};
+template <typename T> class C3;
+template <> class C3<int> {
+ static void g(int = f()); // expected-error {{use of default argument to function 'f' that is declared later in class 'C3'}}
+ static int f(int = 10); // expected-note {{default argument declared here}}
+};
+
// Make sure we actually parse the default argument for an inline definition
class XX {
void A(int length = -1 ) { }
diff --git a/clang/test/SemaCXX/incomplete-call.cpp b/clang/test/SemaCXX/incomplete-call.cpp
index 0fb1ef5f07a5..46f470e4a881 100644
--- a/clang/test/SemaCXX/incomplete-call.cpp
+++ b/clang/test/SemaCXX/incomplete-call.cpp
@@ -1,7 +1,8 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
-struct A; // expected-note 14 {{forward declaration of 'A'}}
+struct A; // expected-note 15 {{forward declaration of 'A'}}
A f(); // expected-note {{'f' declared here}}
+template <typename T> A ft(T); // expected-note {{'ft' declared here}}
struct B {
A f(); // expected-note {{'f' declared here}}
@@ -38,7 +39,8 @@ void g() {
A (B::*mfp)() = 0;
(b.*mfp)(); // expected-error {{calling function with incomplete return type 'A'}}
-
+
+ ft(42); // expected-error {{calling 'ft' with incomplete return type 'A'}}
}
diff --git a/clang/test/SemaCXX/lambda-expressions.cpp b/clang/test/SemaCXX/lambda-expressions.cpp
index 3240d5351fc5..7f7f9c570487 100644
--- a/clang/test/SemaCXX/lambda-expressions.cpp
+++ b/clang/test/SemaCXX/lambda-expressions.cpp
@@ -649,3 +649,14 @@ void Run(const int& points) {
void operator_parens() {
[&](int x){ operator()(); }(0); // expected-error {{undeclared 'operator()'}}
}
+
+namespace captured_name {
+void Test() {
+ union { // expected-note {{'' declared here}}
+ int i;
+ };
+ [] { return i; }; // expected-error {{variable '' cannot be implicitly captured in a lambda with no capture-default specified}}
+ // expected-note at -1 {{lambda expression begins here}}
+
+}
+};
More information about the cfe-commits
mailing list