Commit 8e54705d by Robert Lipe

Another round of improvements from Martin.

From-SVN: r20166
parent d73365c5
// Build don't link: // Build don't link:
#define NO_META_MAX
#ifndef NO_META_MAX
template<int N1, int N2> template<int N1, int N2>
struct meta_max { struct meta_max {
enum { max = (N1 > N2) ? N1 : N2 }; enum { max = (N1 > N2) ? N1 : N2 };
}; };
#endif
struct X { struct X {
enum { enum {
......
...@@ -4,5 +4,5 @@ class C { }; ...@@ -4,5 +4,5 @@ class C { };
void foo() void foo()
{ {
C c; C c;
void * v = static_cast<void *>(c); void * v = static_cast<void *>(c); // ERROR - illegal cast
} }
//Special g++ Options:
//This uses GNU extensions, so disable -ansi
#include <stdio.h> #include <stdio.h>
class A { class A {
......
// Build don't link: // Build don't link:
/* /*
Check whether a typedef for a basic type as a baseclass is diagnosed. Check whether a typedef for a basic type as a baseclass is diagnosed.
*/ */
typedef int an_int; typedef int an_int;
class bar : public an_int {}; // ERROR - class bar : public an_int {}; // ERROR - not an aggregate
...@@ -18,7 +18,7 @@ friend class D; ...@@ -18,7 +18,7 @@ friend class D;
class D { class D {
int ins( B*&); int ins( B*&);
}; }; //WARNING - only private members
int int
D::ins( B*& tempN) D::ins( B*& tempN)
......
...@@ -7,7 +7,7 @@ inline bool operator!=(const T& x, const T& y) { ...@@ -7,7 +7,7 @@ inline bool operator!=(const T& x, const T& y) {
enum T { enum T {
V1, V1,
}; // ERROR - }; //ERROR - comma at end of enumerator list
struct X { struct X {
T t : 31; T t : 31;
......
class foo { class foo {
public: public:
operator <<(const void *); operator <<(const void *); //ERROR - no return type
operator <<(char *); operator <<(char *); //ERROR - no return type
}; };
void main() void main()
{ { //ERROR - wrong return type for main
foo f; foo f;
f << (void*)0; f << (void*)0;
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
template <int n1> template <int n1>
double val <int> () double val <int> ()
{ { // ERROR - bogus code
return (double) n1; return (double) n1;
}; };
......
...@@ -2,5 +2,5 @@ template <unsigned X, class T> struct Foo { ...@@ -2,5 +2,5 @@ template <unsigned X, class T> struct Foo {
friend void operator<<(int, Foo const &) {} friend void operator<<(int, Foo const &) {}
}; };
template <unsigned X> class Bar : public Foo<X,int> {}; template <unsigned X> class Bar : public Foo<X,int> {};
inline Bar<0> bar(int,int,int) { return Bar<3>(); } inline Bar<0> bar(int,int,int) { return Bar<3>(); } // ERROR - no conversion
template<int N> f<0>(){} template<int N> f<0>(){} // ERROR - invalid code
...@@ -26,5 +26,5 @@ inline double Sine() ...@@ -26,5 +26,5 @@ inline double Sine()
int main() int main()
{ {
double f=Sine<32,5>() double f=Sine<32,5>()
return 0; return 0; // ERROR - parse error
} }
...@@ -12,4 +12,4 @@ private: ...@@ -12,4 +12,4 @@ private:
static int variable; // this is intentionally duplicated static int variable; // this is intentionally duplicated
}; };
myClass::variable = 0; myClass::variable = 0; //ERROR - no type
...@@ -13,5 +13,5 @@ ...@@ -13,5 +13,5 @@
void f() void f()
{ {
extent(b); extent(b); // ERROR - no matching function
} }
...@@ -128,7 +128,7 @@ class Baz : public ref_counted { ...@@ -128,7 +128,7 @@ class Baz : public ref_counted {
class Bar; class Bar;
void main() { int main() {
ref_ptr<Baz> foo; ref_ptr<Baz> foo;
static_cast<Bar *> (foo)->DoSomething; static_cast<Bar *> (foo)->DoSomething; //ERROR - invalid cast
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment