Commit c5f2a1f
committed
Fix initialization with resources in structs
This was a bit tricker than I expected, but I think I came up with a
reasonably clever solution.
In HLSL, user-defined data types have aggregate initialization, not
constructors _except_ that some of the builtin types we do model
constructors for. This is actually useful!
In my earlier change I updated DeclCXX so that HLSL non-implicit
classes are always marged as Aggregates. This ends up being not
quite right, because there are some implicit types that should be
aggregates, and others that shouldn't. For example, the implicit
cbuffer-layout types should be aggregates so that we can flatten
them, but resources shouldn't be because we really don't want to
flatten them.
In the update, whether or not an HLSL type is an aggregate is keyed
off having non-implicit "special" members (constructors & operators).
This is more correct.
Aggregate types get flattened out for casting and initialization, while
non-Aggregate types (basically just resources) get left unflattened and
we attempt copy-initialization on them.
Next problem: I was getting some odd conflicting diagnostics when
argument conversion or copy-initialization fails, so I refactored
BuildInitializerList and CastInitializer to return success/failure so
that we can propagate that up and fail if the argument->destination
type fails without then also complaining about the number of
initializers.1 parent 2e1452d commit c5f2a1f
File tree
3 files changed
+64
-37
lines changed- clang
- lib
- AST
- Sema
- test/SemaHLSL/Language
3 files changed
+64
-37
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1468 | 1468 | | |
1469 | 1469 | | |
1470 | 1470 | | |
1471 | | - | |
1472 | | - | |
| 1471 | + | |
| 1472 | + | |
1473 | 1473 | | |
1474 | 1474 | | |
1475 | 1475 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2589 | 2589 | | |
2590 | 2590 | | |
2591 | 2591 | | |
2592 | | - | |
2593 | | - | |
| 2592 | + | |
| 2593 | + | |
| 2594 | + | |
| 2595 | + | |
| 2596 | + | |
| 2597 | + | |
| 2598 | + | |
| 2599 | + | |
| 2600 | + | |
2594 | 2601 | | |
2595 | 2602 | | |
2596 | 2603 | | |
2597 | | - | |
2598 | 2604 | | |
2599 | 2605 | | |
2600 | | - | |
2601 | | - | |
2602 | | - | |
2603 | 2606 | | |
2604 | 2607 | | |
2605 | 2608 | | |
| |||
2608 | 2611 | | |
2609 | 2612 | | |
2610 | 2613 | | |
2611 | | - | |
| 2614 | + | |
2612 | 2615 | | |
2613 | | - | |
| 2616 | + | |
2614 | 2617 | | |
2615 | 2618 | | |
2616 | 2619 | | |
| |||
3062 | 3065 | | |
3063 | 3066 | | |
3064 | 3067 | | |
| 3068 | + | |
| 3069 | + | |
3065 | 3070 | | |
3066 | 3071 | | |
3067 | 3072 | | |
| |||
3074 | 3079 | | |
3075 | 3080 | | |
3076 | 3081 | | |
3077 | | - | |
| 3082 | + | |
3078 | 3083 | | |
3079 | | - | |
3080 | | - | |
3081 | | - | |
3082 | | - | |
3083 | | - | |
| 3084 | + | |
3084 | 3085 | | |
3085 | 3086 | | |
3086 | 3087 | | |
3087 | | - | |
3088 | | - | |
| 3088 | + | |
| 3089 | + | |
| 3090 | + | |
3089 | 3091 | | |
3090 | 3092 | | |
3091 | 3093 | | |
3092 | 3094 | | |
3093 | | - | |
3094 | | - | |
3095 | | - | |
3096 | | - | |
| 3095 | + | |
| 3096 | + | |
| 3097 | + | |
3097 | 3098 | | |
3098 | 3099 | | |
3099 | 3100 | | |
3100 | 3101 | | |
3101 | | - | |
3102 | | - | |
3103 | 3102 | | |
3104 | 3103 | | |
3105 | 3104 | | |
| |||
3109 | 3108 | | |
3110 | 3109 | | |
3111 | 3110 | | |
3112 | | - | |
3113 | | - | |
| 3111 | + | |
| 3112 | + | |
| 3113 | + | |
3114 | 3114 | | |
3115 | | - | |
| 3115 | + | |
3116 | 3116 | | |
3117 | 3117 | | |
3118 | 3118 | | |
| |||
3125 | 3125 | | |
3126 | 3126 | | |
3127 | 3127 | | |
3128 | | - | |
3129 | | - | |
| 3128 | + | |
| 3129 | + | |
| 3130 | + | |
3130 | 3131 | | |
3131 | | - | |
| 3132 | + | |
3132 | 3133 | | |
3133 | 3134 | | |
3134 | 3135 | | |
| |||
3149 | 3150 | | |
3150 | 3151 | | |
3151 | 3152 | | |
3152 | | - | |
3153 | | - | |
| 3153 | + | |
| 3154 | + | |
| 3155 | + | |
3154 | 3156 | | |
3155 | 3157 | | |
3156 | 3158 | | |
| 3159 | + | |
3157 | 3160 | | |
3158 | 3161 | | |
3159 | 3162 | | |
3160 | 3163 | | |
3161 | | - | |
| 3164 | + | |
3162 | 3165 | | |
3163 | 3166 | | |
3164 | 3167 | | |
| |||
3216 | 3219 | | |
3217 | 3220 | | |
3218 | 3221 | | |
3219 | | - | |
3220 | 3222 | | |
3221 | | - | |
| 3223 | + | |
| 3224 | + | |
3222 | 3225 | | |
3223 | | - | |
3224 | | - | |
| 3226 | + | |
| 3227 | + | |
3225 | 3228 | | |
3226 | 3229 | | |
3227 | 3230 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
47 | 57 | | |
48 | 58 | | |
49 | 59 | | |
| |||
87 | 97 | | |
88 | 98 | | |
89 | 99 | | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
0 commit comments