mirror of
https://github.com/Gericom/teak-llvm.git
synced 2025-06-27 15:28:53 -04:00

Remove an atrocious amount of trailing whitespace in the overloaded operator mangler. Sorry, couldn't help myself. Change the DeclType parameter of Sema::CheckReferenceInit to be passed by value instead of reference. It wasn't changed anywhere. Let the parser handle C++'s irregular grammar around assignment-expression and conditional-expression. And finally, the reason for all this stuff: implement C++ semantics for the conditional operator. The implementation is complete except for determining lvalueness. llvm-svn: 69299
64 lines
2.0 KiB
C++
64 lines
2.0 KiB
C++
// RUN: clang-cc -fsyntax-only -verify %s
|
|
class X {
|
|
public:
|
|
operator bool();
|
|
operator int() const;
|
|
|
|
bool f() {
|
|
return operator bool();
|
|
}
|
|
|
|
float g() {
|
|
return operator float(); // expected-error{{no matching function for call to 'operator float'}}
|
|
}
|
|
};
|
|
|
|
operator int(); // expected-error{{conversion function must be a non-static member function}}
|
|
|
|
operator int; // expected-error{{'operator int' cannot be the name of a variable or data member}}
|
|
|
|
typedef int func_type(int);
|
|
typedef int array_type[10];
|
|
|
|
class Y {
|
|
public:
|
|
void operator bool(int, ...) const; // expected-error{{conversion function cannot have a return type}} \
|
|
// expected-error{{conversion function cannot have any parameters}} \
|
|
// expected-error{{conversion function cannot be variadic}}
|
|
operator func_type(); // expected-error{{conversion function cannot convert to a function type}}
|
|
operator array_type(); // expected-error{{conversion function cannot convert to an array type}}
|
|
};
|
|
|
|
|
|
typedef int INT;
|
|
typedef INT* INT_PTR;
|
|
|
|
class Z {
|
|
operator int(); // expected-note {{previous declaration is here}}
|
|
operator int**(); // expected-note {{previous declaration is here}}
|
|
|
|
operator INT(); // expected-error{{conversion function cannot be redeclared}}
|
|
operator INT_PTR*(); // expected-error{{conversion function cannot be redeclared}}
|
|
};
|
|
|
|
|
|
class A { };
|
|
|
|
class B : public A {
|
|
public:
|
|
operator A&() const; // expected-warning{{conversion function converting 'class B' to its base class 'class A' will never be used}}
|
|
operator const void() const; // expected-warning{{conversion function converting 'class B' to 'void const' will never be used}}
|
|
operator const B(); // expected-warning{{conversion function converting 'class B' to itself will never be used}}
|
|
};
|
|
|
|
// This used to crash Clang.
|
|
struct Flip;
|
|
struct Flop {
|
|
Flop();
|
|
Flop(const Flip&);
|
|
};
|
|
struct Flip {
|
|
operator Flop() const;
|
|
};
|
|
Flop flop = Flip(); // expected-error {{cannot initialize 'flop' with an rvalue of type 'struct Flip'}}
|