aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-02-19 23:45:49 +0000
committerChris Lattner <sabre@nondot.org>2009-02-19 23:45:49 +0000
commitd0344a4a6182ad704881cbbaa21cca14913d2296 (patch)
tree61b23aebb6f09877ef079f9fc32c30ff249da2f5 /test
parent58e899b336c63fa25d4cc8986d97a40933cded9b (diff)
Fix a long standard problem with clang retaining "too much" sugar
information about types. We often print diagnostics where we say "foo_t" is bad, but the user doesn't know how foo_t is declared (because it is a typedef). Fix this by expanding sugar when present in a diagnostic (and not one of a few special cases, like vectors). Before: t.m:5:2: error: invalid operands to binary expression ('typeof(P)' and 'typeof(F)') MAX(P, F); ^~~~~~~~~ t.m:1:78: note: instantiated from: #define MAX(A,B) ({ __typeof__(A) __a = (A); __typeof__(B) __b = (B); __a < __b ? __b : __a; }) ^ After: t.m:5:2: error: invalid operands to binary expression ('typeof(P)' (aka 'struct mystruct') and 'typeof(F)' (aka 'float')) MAX(P, F); ^~~~~~~~~ t.m:1:78: note: instantiated from: #define MAX(A,B) ({ __typeof__(A) __a = (A); __typeof__(B) __b = (B); __a < __b ? __b : __a; }) ^ git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65081 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/Sema/declspec.c8
-rw-r--r--test/Sema/exprs.c9
-rw-r--r--test/Sema/types.c2
-rw-r--r--test/SemaCXX/const-cast.cpp4
-rw-r--r--test/SemaCXX/constructor-initializer.cpp2
-rw-r--r--test/SemaCXX/destructor.cpp2
-rw-r--r--test/SemaCXX/inherit.cpp4
-rw-r--r--test/SemaCXX/overloaded-operator-decl.cpp2
-rw-r--r--test/SemaCXX/typedef-redecl.cpp2
-rw-r--r--test/SemaTemplate/class-template-decl.cpp2
10 files changed, 23 insertions, 14 deletions
diff --git a/test/Sema/declspec.c b/test/Sema/declspec.c
index 6e29625792..0207b4aacc 100644
--- a/test/Sema/declspec.c
+++ b/test/Sema/declspec.c
@@ -16,8 +16,8 @@ static void buggy(int *x) { } // expected-error {{function definition declared '
// Type qualifiers.
typedef int f(void);
typedef f* fptr;
-const f* v1; // expected-warning {{qualifier on function type 'f' has unspecified behavior}}
-__restrict__ f* v2; // expected-error {{restrict requires a pointer or reference ('f' is invalid)}}
-__restrict__ fptr v3; // expected-error {{pointer to function type 'f' may not be 'restrict' qualified}}
-f *__restrict__ v4; // expected-error {{pointer to function type 'f' may not be 'restrict' qualified}}
+const f* v1; // expected-warning {{qualifier on function type 'f' (aka 'int (void)') has unspecified behavior}}
+__restrict__ f* v2; // expected-error {{restrict requires a pointer or reference ('f' (aka 'int (void)') is invalid)}}
+__restrict__ fptr v3; // expected-error {{pointer to function type 'f' (aka 'int (void)') may not be 'restrict' qualified}}
+f *__restrict__ v4; // expected-error {{pointer to function type 'f' (aka 'int (void)') may not be 'restrict' qualified}}
diff --git a/test/Sema/exprs.c b/test/Sema/exprs.c
index 4ddb976eb2..ba411c528d 100644
--- a/test/Sema/exprs.c
+++ b/test/Sema/exprs.c
@@ -64,3 +64,12 @@ void test10(int n,...) {
} s;
double x = s.a[0]; // should not get another error here.
}
+
+
+#define MYMAX(A,B) __extension__ ({ __typeof__(A) __a = (A); __typeof__(B) __b = (B); __a < __b ? __b : __a; })
+
+struct mystruct {int A; };
+void foo(struct mystruct P, float F) {
+ MYMAX(P, F); // expected-error {{invalid operands to binary expression ('typeof(P)' (aka 'struct mystruct') and 'typeof(F)' (aka 'float'))}}
+}
+
diff --git a/test/Sema/types.c b/test/Sema/types.c
index 208abce3d9..da02588461 100644
--- a/test/Sema/types.c
+++ b/test/Sema/types.c
@@ -5,6 +5,6 @@ typedef int (*T)[2];
restrict T x;
typedef int *S[2];
-restrict S y; // expected-error {{restrict requires a pointer or reference ('S' is invalid)}}
+restrict S y; // expected-error {{restrict requires a pointer or reference ('S' (aka 'int *[2]') is invalid)}}
diff --git a/test/SemaCXX/const-cast.cpp b/test/SemaCXX/const-cast.cpp
index 0c334bf9fa..8424cf28d9 100644
--- a/test/SemaCXX/const-cast.cpp
+++ b/test/SemaCXX/const-cast.cpp
@@ -29,7 +29,7 @@ char ***good_const_cast_test(ccvpcvpp var)
// Drop reference. Intentionally without qualifier change.
char *** var5 = const_cast<cppp>(var4);
const int ar[100] = {0};
- int (&rar)[100] = const_cast<iarr>(ar); // expected-error {{const_cast from 'int const [100]' to 'iarr' is not allowed}}
+ int (&rar)[100] = const_cast<iarr>(ar); // expected-error {{const_cast from 'int const [100]' to 'iarr' (aka 'iar &') is not allowed}}
// Array decay. Intentionally without qualifier change.
int *pi = const_cast<int*>(ar);
f fp = 0;
@@ -56,7 +56,7 @@ short *bad_const_cast_test(char const *volatile *const volatile *var)
int *(*rar)[100] = const_cast<int *(*)[100]>(&ar); // expected-error {{const_cast from 'int const *(*)[100]' to 'int *(*)[100]' is not allowed}}
f fp1 = 0;
// Function pointers.
- f fp2 = const_cast<f>(fp1); // expected-error {{const_cast to 'f', which is not a reference, pointer-to-object, or pointer-to-data-member}}
+ f fp2 = const_cast<f>(fp1); // expected-error {{const_cast to 'f' (aka 'int (*)(int)'), which is not a reference, pointer-to-object, or pointer-to-data-member}}
void (A::*mfn)() = 0;
(void)const_cast<void (A::*)()>(mfn); // expected-error {{const_cast to 'void (struct A::*)(void)', which is not a reference, pointer-to-object, or pointer-to-data-member}}
return **var3;
diff --git a/test/SemaCXX/constructor-initializer.cpp b/test/SemaCXX/constructor-initializer.cpp
index a79b6caac9..ded9010749 100644
--- a/test/SemaCXX/constructor-initializer.cpp
+++ b/test/SemaCXX/constructor-initializer.cpp
@@ -37,7 +37,7 @@ public:
F() : B(17),
m(17), // expected-error{{member initializer 'm' does not name a non-static data member or base class}}
- INT(17) // expected-error{{constructor initializer 'INT' does not name a class}}
+ INT(17) // expected-error{{constructor initializer 'INT' (aka 'int') does not name a class}}
{
}
};
diff --git a/test/SemaCXX/destructor.cpp b/test/SemaCXX/destructor.cpp
index 2134f4ec5c..f5b35cbfd3 100644
--- a/test/SemaCXX/destructor.cpp
+++ b/test/SemaCXX/destructor.cpp
@@ -27,7 +27,7 @@ struct E;
typedef E E_typedef;
struct E {
- ~E_typedef(); // expected-error{{destructor cannot be declared using a typedef 'E_typedef' of the class name}}
+ ~E_typedef(); // expected-error{{destructor cannot be declared using a typedef 'E_typedef' (aka 'struct E') of the class name}}
};
struct F {
diff --git a/test/SemaCXX/inherit.cpp b/test/SemaCXX/inherit.cpp
index 6c00218039..7e04052c40 100644
--- a/test/SemaCXX/inherit.cpp
+++ b/test/SemaCXX/inherit.cpp
@@ -28,5 +28,5 @@ typedef G G_copy;
typedef G G_copy_2;
typedef G_copy G_copy_3;
-class H : G_copy, A, G_copy_2, // expected-error{{base class 'G_copy' specified more than once as a direct base class}}
- public G_copy_3 { }; // expected-error{{base class 'G_copy' specified more than once as a direct base class}}
+class H : G_copy, A, G_copy_2, // expected-error{{base class 'G_copy' (aka 'class G') specified more than once as a direct base class}}
+ public G_copy_3 { }; // expected-error{{base class 'G_copy' (aka 'class G') specified more than once as a direct base class}}
diff --git a/test/SemaCXX/overloaded-operator-decl.cpp b/test/SemaCXX/overloaded-operator-decl.cpp
index 812ac7ff8b..8008b20007 100644
--- a/test/SemaCXX/overloaded-operator-decl.cpp
+++ b/test/SemaCXX/overloaded-operator-decl.cpp
@@ -34,6 +34,6 @@ typedef int INT;
typedef float FLOAT;
Y& operator++(Y&);
Y operator++(Y&, INT);
-X operator++(X&, FLOAT); // expected-error{{parameter of overloaded post-increment operator must have type 'int' (not 'FLOAT')}}
+X operator++(X&, FLOAT); // expected-error{{parameter of overloaded post-increment operator must have type 'int' (not 'FLOAT' (aka 'float'))}}
int operator+; // expected-error{{'operator+' cannot be the name of a variable or data member}}
diff --git a/test/SemaCXX/typedef-redecl.cpp b/test/SemaCXX/typedef-redecl.cpp
index 016882feb2..c7e7d45284 100644
--- a/test/SemaCXX/typedef-redecl.cpp
+++ b/test/SemaCXX/typedef-redecl.cpp
@@ -3,7 +3,7 @@ typedef int INT;
typedef INT REALLY_INT; // expected-note {{previous definition is here}}
typedef REALLY_INT REALLY_REALLY_INT;
typedef REALLY_INT BOB;
-typedef float REALLY_INT; // expected-error{{typedef redefinition with different types ('float' vs 'INT')}}
+typedef float REALLY_INT; // expected-error{{typedef redefinition with different types ('float' vs 'INT' (aka 'int'))}}
struct X {
typedef int result_type; // expected-note {{previous definition is here}}
diff --git a/test/SemaTemplate/class-template-decl.cpp b/test/SemaTemplate/class-template-decl.cpp
index 3978e1f04a..ff38132928 100644
--- a/test/SemaTemplate/class-template-decl.cpp
+++ b/test/SemaTemplate/class-template-decl.cpp
@@ -25,7 +25,7 @@ template<int N> class NonTypeTemplateParm;
typedef int INT;
-template<INT M> class NonTypeTemplateParm; // expected-note{{previous non-type template parameter with type 'INT' is here}}
+template<INT M> class NonTypeTemplateParm; // expected-note{{previous non-type template parameter with type 'INT' (aka 'int') is here}}
template<long> class NonTypeTemplateParm; // expected-error{{template non-type parameter has a different type 'long' in template redeclaration}}