| 1 |
// { dg-do assemble } |
| 2 |
//980205 bkoz |
| 3 |
|
| 4 |
//7.1.3 the typedef specifier |
| 5 |
|
| 6 |
|
| 7 |
//p1 |
| 8 |
typedef int MILES, *KLICKSP; |
| 9 |
MILES distance; |
| 10 |
extern KLICKSP metricp; |
| 11 |
|
| 12 |
//p2--can redefine to same type |
| 13 |
typedef struct s { /* ... */ } s; |
| 14 |
typedef int I; |
| 15 |
typedef int I; |
| 16 |
typedef I I; |
| 17 |
|
| 18 |
//p3--cannot redefine to a different type in a given scope |
| 19 |
class complex2 { /* ... */ };// { dg-message "" } .* |
| 20 |
typedef int complex2;// { dg-error "" } .* |
| 21 |
typedef int complex3;// { dg-message "" } .* |
| 22 |
class complex3 { /* ... */ };// { dg-error "" } .* |
| 23 |
|
| 24 |
|
| 25 |
//p4 |
| 26 |
/* |
| 27 |
4 A typedef-name that names a class is a class-name (_class.name_). If |
| 28 |
a typedef-name is used |
| 29 |
1) following the class-key in an elaborated-type-specifier |
| 30 |
2) or in the class-head of a class declaration |
| 31 |
3) or is used as the identifier in the declarator for a |
| 32 |
constructor or destructor declaration |
| 33 |
the program is ill-formed. [Example: |
| 34 |
*/ |
| 35 |
struct S { |
| 36 |
S(); |
| 37 |
~S(); |
| 38 |
}; |
| 39 |
|
| 40 |
typedef struct S T; // { dg-message "previous declaration" } |
| 41 |
|
| 42 |
S a = T(); // OK |
| 43 |
struct T * p; // { dg-error "" } using typedef after struct |
| 44 |
|
| 45 |
//case01 |
| 46 |
typedef bool short;// { dg-error "" } .* |